diff --git a/.gitignore b/.gitignore index 795af2a..7e2ea7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.o +*.exe Makefile Makefile.in /aclocal.m4 diff --git a/README b/README index e51e025..e91d3be 100644 --- a/README +++ b/README @@ -14,7 +14,7 @@ Usage The options are controlled with simple key commands: d Next webcam device - f Toggle fullscreen view + f Toggle fullscreen view (non-win32 only) i Invert the colors c Next color pair l Increment line size @@ -34,10 +34,15 @@ For systems where Autotools is supported, simply use: $ make $ 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 ------------ -OpenCV 2.3 is used to grab frames from the webcam and process them. -You'll need at least the `cxcore` and `highgui` libraries. - -OpenCV can be optained from: http://opencv.willowgarage.com +OpenCV 2.3 is used to grab frames from the webcam and process them. It +can be optained from: http://opencv.willowgarage.com diff --git a/src/config.c b/src/config.c index c7ab04b..6943a86 100644 --- a/src/config.c +++ b/src/config.c @@ -23,6 +23,10 @@ * TODO: ensure this file is portable */ +#ifdef HAVE_WINDOWS +#include +#endif + #include #include #include @@ -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) { /* FIXME */ char command[PATH_MAX + 11] = { 0 }; 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)); +#endif (void) system(command); free(path); } diff --git a/src/main.c b/src/main.c index 7f2942a..7c3dc5f 100644 --- a/src/main.c +++ b/src/main.c @@ -151,7 +151,14 @@ int main(int argc, char *argv[]) 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); handle = cvGetWindowHandle(conf->title); name = cvGetWindowName(handle); diff --git a/win32/makefile.win32 b/win32/makefile.win32 new file mode 100644 index 0000000..e12f546 --- /dev/null +++ b/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