Skip to content

Commit

Permalink
Add makefile.win32 and other minor changes for build on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
codebrainz committed Nov 21, 2011
1 parent 2cbdd5d commit 1fdfc05
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,4 +1,5 @@
*.o *.o
*.exe
Makefile Makefile
Makefile.in Makefile.in
/aclocal.m4 /aclocal.m4
Expand Down
15 changes: 10 additions & 5 deletions README
Expand Up @@ -14,7 +14,7 @@ Usage
The options are controlled with simple key commands: The options are controlled with simple key commands:


d Next webcam device d Next webcam device
f Toggle fullscreen view f Toggle fullscreen view (non-win32 only)
i Invert the colors i Invert the colors
c Next color pair c Next color pair
l Increment line size l Increment line size
Expand All @@ -34,10 +34,15 @@ For systems where Autotools is supported, simply use:
$ make $ make
$ make install # possibly as root depending on prefix $ make install # possibly as root depending on prefix


For Windows, install Mingw and OpenCV and make sure their `bin`
directories are the PATH environment variable. Then edit the first
variable in `win32/makefile.win32` to point to the installation prefix
for you OpenCV installation. After, change into the `win32` directory
and run `mingw32-make -f makefile.win32`. If everything went properly
there should be a `digimag.exe` file in that directory.

Dependencies Dependencies
------------ ------------


OpenCV 2.3 is used to grab frames from the webcam and process them. OpenCV 2.3 is used to grab frames from the webcam and process them. It
You'll need at least the `cxcore` and `highgui` libraries. can be optained from: http://opencv.willowgarage.com

OpenCV can be optained from: http://opencv.willowgarage.com
22 changes: 22 additions & 0 deletions src/config.c
Expand Up @@ -23,6 +23,10 @@
* TODO: ensure this file is portable * TODO: ensure this file is portable
*/ */


#ifdef HAVE_WINDOWS
#include <windows.h>
#endif

#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <libgen.h> #include <libgen.h>
Expand Down Expand Up @@ -159,12 +163,30 @@ static int on_ini_entry(void *user, const char *section, const char *name,
} }




#ifdef HAVE_WINDOWS
BOOL FileExists(LPCTSTR szPath)
{
DWORD dwAttrib = GetFileAttributes(szPath);
return (dwAttrib != INVALID_FILE_ATTRIBUTES);
}
#endif


static void config_create(void) static void config_create(void)
{ {
/* FIXME */ /* FIXME */
char command[PATH_MAX + 11] = { 0 }; char command[PATH_MAX + 11] = { 0 };
char *path = strdup(config_get_path()); char *path = strdup(config_get_path());
#ifdef HAVE_WINDOWS
if (FileExists(dirname(path)))
{
free(path);
return;
}
snprintf(command, PATH_MAX + 11, "mkdir \"%s\"", dirname(path));
#else
snprintf(command, PATH_MAX + 11, "mkdir -p \"%s\"", dirname(path)); snprintf(command, PATH_MAX + 11, "mkdir -p \"%s\"", dirname(path));
#endif
(void) system(command); (void) system(command);
free(path); free(path);
} }
Expand Down
9 changes: 8 additions & 1 deletion src/main.c
Expand Up @@ -151,7 +151,14 @@ int main(int argc, char *argv[])


open_device(conf); open_device(conf);


cvNamedWindow(conf->title, 0); #ifndef HAVE_WINDOWS
cvNamedWindow(conf->title, CV_WINDOW_NORMAL | CV_WINDOW_KEEPRATIO);
#else
/* Windows doesn't support fullscreen and doesn't keep aspect ration
* even with CV_WINDOW_KEEPRATIO. */
cvNamedWindow(conf->title, CV_WINDOW_AUTOSIZE | CV_WINDOW_KEEPRATIO);
#endif

cvSetMouseCallback(conf->title, on_mouse_callback, conf); cvSetMouseCallback(conf->title, on_mouse_callback, conf);
handle = cvGetWindowHandle(conf->title); handle = cvGetWindowHandle(conf->title);
name = cvGetWindowName(handle); name = cvGetWindowName(handle);
Expand Down
34 changes: 34 additions & 0 deletions win32/makefile.win32
@@ -0,0 +1,34 @@
# Adjust this to where you installed OpenCV
OPENCV_INSTALL_PREFIX = C:/OpenCV/install

CFLAGS = \
-D_WIN32 -DHAVE_WINDOWS=1 \
-I$(OPENCV_INSTALL_PREFIX)/include/opencv \
-I$(OPENCV_INSTALL_PREFIX)/include

LDFLAGS = \
-L$(OPENCV_INSTALL_PREFIX)/lib \
-lopencv_calib3d231 \
-lopencv_contrib231 \
-lopencv_core231 \
-lopencv_features2d231 \
-lopencv_flann231 \
-lopencv_gpu231 \
-lopencv_highgui231 \
-lopencv_imgproc231 \
-lopencv_legacy231 \
-lopencv_ml231 \
-lopencv_objdetect231 \
-lopencv_ts231 \
-lopencv_video231

SOURCES = \
../src/main.c \
../src/ini.c ../src/ini.h \
../src/config.c ../src/config.h

digimag.exe: $(SOURCES)
gcc $(CFLAGS) -o $@ $^ $(LDFLAGS)

clean:
del digimag.exe

0 comments on commit 1fdfc05

Please sign in to comment.