-
-
Notifications
You must be signed in to change notification settings - Fork 171
Fixes for MSVC 2013 #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for MSVC 2013 #163
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| Requirements | ||
| ------------ | ||
|
|
||
| - MinGW | ||
| http://mingw-w64.sourceforge.net/ | ||
| (Actually I used tdm64-gcc-4.9.2-3 but this should make no difference. http://tdm-gcc.tdragon.net/download) | ||
| See README.win32 for instructions on how to get MinGW-w64, be sure to get the 64-bit Windows archive. | ||
|
|
||
| - CMake | ||
| http://www.cmake.org/cmake/resources/software.html | ||
| - OpenCV | ||
| http://sourceforge.net/projects/opencvlibrary/files/opencv-win/ | ||
| - Git | ||
| http://code.google.com/p/msysgit/ | ||
|
|
||
| 1. Clone the PS Move API repository | ||
|
|
||
| git clone --recursive https://github.com/cboulay/psmoveapi.git | ||
| cd psmoveapi | ||
|
|
||
| 2. Get libusb-1.0 built binaries (Needed for PS3EYEDriver use in tracker) | ||
| http://libusb.info/ | ||
| Downloads -> latest windows binaries | ||
| Unpack into psmoveapi\external\libusb-1.0 | ||
|
|
||
| 3. Build OpenCV repository (Needed for tracker) | ||
| Download opencv-2.4.11.zip from http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/ | ||
| (Yes, I know it says unix, but all we need are the sources.) | ||
| Unpack it into psmoveapi\ and trim the version off the directory name (i.e. psmoveapi\opencv) | ||
| Open a MinGW command prompt to the psmoveapi\opencv directory. | ||
| mkdir build | ||
| cd build | ||
| cmake .. -G "MinGW Makefiles" -DBUILD_SHARED_LIBS=0 -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_DOCS=OFF -DBUILD_opencv_flann=OFF -DBUILD_opencv_features2d=OFF -DBUILD_opencv_objdetect=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_ts=OFF -DBUILD_opencv_ml=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_java=OFF -DWITH_OPENEXR=OFF -DWITH_FFMPEG=OFF -DWITH_JASPER=OFF -DWITH_TIFF=OFF | ||
| mingw32-make -j4 | ||
| mingw32-make install | ||
|
|
||
| 4. Build psmoveapi | ||
|
|
||
| cd ..\.. | ||
| mkdir build | ||
| cd build | ||
| SET CMAKE_CXX_FLAGS=%CMAKE_CXX_FLAGS% -std=c++11 | ||
| cmake .. -G "MinGW Makefiles" -DPSMOVE_BUILD_PYTHON_BINDINGS=0 -DPSMOVE_USE_LOCAL_OPENCV=1 -DPSMOVE_USE_MADGWICK_AHRS=1 -DPSMOVE_USE_PS3EYE_DRIVER=1 -DPSMOVE_USE_LOCAL_LIBUSB=1 | ||
| mingw32-make | ||
|
|
||
| 5. Read WINDOWS_EXTRA for windows-specific information on pairing and connecting the psmove controller and on using the PS3Eye camera. | ||
|
|
||
| 6. Start one of the desired test applications | ||
|
|
||
| If you previously chose to build the example applications (which is the | ||
| default), you can then run | ||
|
|
||
| example.exe | ||
|
|
||
| for a basic example. | ||
|
|
||
| For questions, please read the archives of the PS Move Mailing List. If you | ||
| cannot find an answer to your question in the archives, send an e-mail: | ||
|
|
||
| https://groups.google.com/forum/#!aboutgroup/psmove | ||
|
|
||
| 7. If you intend to build the libraries with MinGW but use with MSVC, http://www.mingw.org/wiki/MSVC_and_MinGW_DLLs | ||
|
|
||
| Option 1 to create the DEF files is to edit CMakeLists.txt. For example, | ||
| if (MINGW) | ||
| set_target_properties(psmoveapi_tracker PROPERTIES LINK_FLAGS "-Wl,--output-def,libpsmoveapi_tracker.def") | ||
| endif (MINGW) | ||
|
|
||
| Option 2 is to hand-craft them. https://wiki.videolan.org/GenerateLibFromDll | ||
| Open a MSVC command prompt to the directory where you built the libraries. | ||
| dumpbin /exports libpsmoveapi.dll > libpsmoveapi.def | ||
| dumpbin /exports libpsmoveapi_tracker.dll > libpsmoveapi_tracker.def | ||
| Now edit each def so the first line is EXPORTS and the remaining lines are the symbol names. | ||
|
|
||
| lib /MACHINE:X64 /DEF:libpsmoveapi.def | ||
| lib /MACHINE:X64 /DEF:libpsmoveapi_tracker.def |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| Requirements | ||
| ------------ | ||
|
|
||
| - Visual Studio Community 2013 | ||
| http://www.visualstudio.com/en-us/news/vs2013-community-vs.aspx | ||
| - CMake | ||
| http://www.cmake.org/cmake/resources/software.html | ||
| - OpenCV | ||
| http://sourceforge.net/projects/opencvlibrary/files/opencv-win/ | ||
| - Git | ||
| http://code.google.com/p/msysgit/ | ||
|
|
||
| 1. Clone the PS Move API repository | ||
| `git clone --recursive https://github.com/cboulay/psmoveapi.git` | ||
| `cd psmoveapi` | ||
|
|
||
| 2. Get libusb-1.0 | ||
| Go to http://libusb.info/ and download the latest source (tarball). | ||
| Unpack the folder into psmoveapi\external\ and rename the folder to libusb-1.0 | ||
| i.e. psmoveapi\external\libusb-1.0 | ||
|
|
||
| In that folder, open msvc\libusb_2013.sln | ||
| Change the target to Release x64 (at the top of the Visual Studio window). | ||
| Build the solution. | ||
|
|
||
| 3. OpenCV | ||
| Download opencv-2.4.11.zip from http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/ | ||
| (Yes, I know it says unix, but all we need are the sources.) | ||
| Unpack it into psmoveapi\ and trim the version off the directory name (i.e. psmoveapi\opencv) | ||
|
|
||
| Open a VS2013 command prompt to the psmoveapi\opencv directory: | ||
|
|
||
| `mkdir build` | ||
| `cd build` | ||
| `cmake .. -G "Visual Studio 12 Win64" -DBUILD_SHARED_LIBS=0 -DBUILD_WITH_STATIC_CRT=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_TESTS=OFF -DBUILD_DOCS=OFF -DBUILD_opencv_apps=OFF -DBUILD_opencv_flann=OFF -DBUILD_opencv_features2d=OFF -DBUILD_opencv_objdetect=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_ts=OFF -DBUILD_opencv_ml=OFF -DBUILD_opencv_video=OFF -DBUILD_opencv_java=OFF -DWITH_OPENEXR=OFF -DWITH_FFMPEG=OFF -DWITH_JASPER=OFF -DWITH_TIFF=OFF` | ||
|
|
||
| Open the solution in psmoveapi\opencv\build\OpenCV.sln | ||
| Change the target to Release (at the top of the Visual Studio window). | ||
| Build the solution. | ||
|
|
||
| 4. Build psmoveapi | ||
|
|
||
| Still in the VS2013 command prompt: | ||
|
|
||
| `cd ..\..` | ||
| `mkdir build ` | ||
| `cd build` | ||
| `cmake .. -G "Visual Studio 12 Win64" -DPSMOVE_BUILD_PYTHON_BINDINGS=0 -DPSMOVE_USE_LOCAL_OPENCV=1 -DPSMOVE_USE_MADGWICK_AHRS=1 -DPSMOVE_USE_PS3EYE_DRIVER=1 -DPSMOVE_USE_LOCAL_LIBUSB=1` | ||
|
|
||
| Open the solution file. | ||
| Change the target to Release. | ||
| Build the projects psmoveapi, psmoveapi_tracker, and test_tracker (others untested). | ||
|
|
||
| 5. Read WINDOWS_EXTRA for windows-specific information on pairing and connecting the psmove controller and on using the PS3Eye camera. | ||
|
|
||
| 6. Start one of the desired test applications | ||
|
|
||
| If you previously chose to build the example applications (which is the | ||
| default), you can then run | ||
|
|
||
| example.exe | ||
|
|
||
| for a basic example. | ||
|
|
||
| For questions, please read the archives of the PS Move Mailing List. If you | ||
| cannot find an answer to your question in the archives, send an e-mail: | ||
|
|
||
| https://groups.google.com/forum/#!aboutgroup/psmove |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| There are a few quirks in Windows that make it somewhat difficult to use the psmoveapi. | ||
| While we continue to work to make it simpler, the following work-arounds may be necessary. | ||
|
|
||
| Pairing the controller to the host | ||
| ================================== | ||
|
|
||
| Using the controllers' Bluetooth capabilities requires you to pair the | ||
| controller to the host computer first. That is what the psmovepair utility | ||
| is for. It is automatically built as part of the PS Move API. | ||
|
|
||
| Make sure that Bluetooth is enabled on your computer, then connect a Move | ||
| controller via USB and run | ||
|
|
||
| psmovepair.exe | ||
|
|
||
| to store the host's Bluetooth device address in the Move and register the | ||
| controller. | ||
|
|
||
| Try the remaining onscreen instructions but pairing is likely to fail at this point, then just Ctrl+C out of the program. | ||
|
|
||
| Reboot your computer. (Maybe not necessary, but it reportedly helps some.) | ||
|
|
||
| In Windows 8.1: | ||
|
|
||
| Open "Devices and Printers." | ||
| You should see a grayed out Motion Controller device. | ||
| Double click on it to open its properties. | ||
| Click on the "Services" tab. We are looking for a checkbox "Drivers for keyboard, mice, etc (HID)" | ||
| If the box is unavailable, try pressing the PS button on your controller. | ||
| If that still does not make the box available, try running [psmove-pair-win](https://github.com/nitsch/psmove-pair-win). | ||
| When the box is available, check it. | ||
| Click OK. | ||
| Open regedit. | ||
| Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HidBth\Parameters\Devices | ||
| You will likely only have one key there for your device. Change its VirtuallyCabled DWORD value to 1. | ||
| Reboot. | ||
|
|
||
| You should now be able to pair immediately by pressing the PS button on the controller. | ||
| If that fails then try the [psmove-pair-win] utility again. | ||
|
|
||
| PS3EYE Camera | ||
| ============= | ||
|
|
||
| The PS3EYE Camera works in Windows using either the CLEyeDriver (32-bit programs only, non-free) | ||
| or the PS3EYEDriver. The PS3EYEDriver should work with 32-bit or 64-bit programs, and it is free. | ||
|
|
||
| If you intend to use the PS3Eye camera then you currently need a registry entry for it. | ||
| Double click the provided ps3eye_settings.reg to enter the registry settings. | ||
|
|
||
| In Windows 8.1: | ||
| The camera shows up as two interfaces to a single device. | ||
| The two interfaces are not distinguishable except that only the camera can be opened. | ||
| We have modified the PS3EYEDriver to work around this behaviour. | ||
|
|
||
| If you are still getting crashes when trying to use the PS3EYEDriver in Windows, | ||
| then please report the problem in github. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,16 +104,17 @@ save(int i, int roi_size, struct TestContext *context) | |
| cvSaveImage(path, frame, imgParams); | ||
| } | ||
|
|
||
| #define cROIS 3 | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Named constant macros should be all-uppercase, maybe use |
||
| int | ||
| main(int argc, char *argv[]) | ||
| { | ||
| printf("\n -- PS Move API ROI Performance Test -- \n\n"); | ||
| int roi_sizes[] = {480, 240, 120}; | ||
| int roi_sizes[cROIS] = { 480, 240, 120 }; | ||
| int roi; | ||
| int rois = sizeof(roi_sizes)/sizeof(roi_sizes[0]); | ||
|
|
||
| float data[ITERATIONS][rois]; | ||
| float position[ITERATIONS][rois][3]; // x, y, r | ||
| //int rois = sizeof(roi_sizes) / sizeof(roi_sizes[0]); // MSVC is too stupid to figure out this is a constant. See cROIS above. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented out code. |
||
| float data[ITERATIONS][cROIS]; | ||
| float position[ITERATIONS][cROIS][3]; // x, y, r | ||
|
|
||
| /** | ||
| * Test file for this test is available from: | ||
|
|
@@ -124,12 +125,15 @@ main(int argc, char *argv[]) | |
| putenv(PSMOVE_TRACKER_FILENAME_ENV "=test_roi_size.avi"); | ||
| putenv(PSMOVE_TRACKER_COLOR_ENV "=723a8c"); | ||
|
|
||
| for (roi=0; roi<rois; roi++) { | ||
| for (roi = 0; roi<cROIS; roi++) { | ||
| printf("Testing tracking performance: %d\n", roi_sizes[roi]); | ||
|
|
||
| char tmp[strlen(PSMOVE_TRACKER_ROI_SIZE_ENV) + 10]; | ||
| //char tmp[strlen(PSMOVE_TRACKER_ROI_SIZE_ENV) + 10]; //msvc cannot handle variable length arrays, and is too stupid to figure out this is constant. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented out code. |
||
| char *tmp; | ||
| tmp = calloc(strlen(PSMOVE_TRACKER_ROI_SIZE_ENV) + 10, sizeof(char)); | ||
| sprintf(tmp, "%s=%d", PSMOVE_TRACKER_ROI_SIZE_ENV, roi_sizes[roi]); | ||
| putenv(tmp); | ||
| free(tmp); | ||
|
|
||
| struct TestContext context; | ||
| setup(&context); | ||
|
|
@@ -169,10 +173,10 @@ main(int argc, char *argv[]) | |
|
|
||
| /* Header */ | ||
| fprintf(fp, "frame"); | ||
| for (roi=0; roi<rois; roi++) { | ||
| for (roi = 0; roi<cROIS; roi++) { | ||
| fprintf(fp, ",roi%d", roi_sizes[roi]); | ||
| } | ||
| for (roi=0; roi<rois; roi++) { | ||
| for (roi = 0; roi<cROIS; roi++) { | ||
| fprintf(fp, ",x%d,y%d,r%d", | ||
| roi_sizes[roi], | ||
| roi_sizes[roi], | ||
|
|
@@ -184,10 +188,10 @@ main(int argc, char *argv[]) | |
| int i; | ||
| for (i=0; i<ITERATIONS; i++) { | ||
| fprintf(fp, "%d", i); | ||
| for (roi=0; roi<rois; roi++) { | ||
| for (roi = 0; roi<cROIS; roi++) { | ||
| fprintf(fp, ",%.10f", data[i][roi]); | ||
| } | ||
| for (roi=0; roi<rois; roi++) { | ||
| for (roi = 0; roi<cROIS; roi++) { | ||
| fprintf(fp, ",%.10f,%.10f,%.10f", | ||
| position[i][roi][0], | ||
| position[i][roi][1], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,13 +44,15 @@ | |
| int main(int arg, char** args) { | ||
| int i; | ||
| int count = psmove_count_connected(); | ||
| PSMove* controllers[count]; | ||
| //PSMove* controllers[count]; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented out code. |
||
|
|
||
| printf("### Found %d controllers.\n", count); | ||
| if (count == 0) { | ||
| return 1; | ||
| } | ||
|
|
||
| PSMove **controllers = (PSMove **)calloc(count, sizeof(PSMove *)); | ||
|
|
||
| void *frame; | ||
| int result; | ||
|
|
||
|
|
@@ -111,6 +113,7 @@ int main(int arg, char** args) { | |
| } | ||
|
|
||
| psmove_tracker_free(tracker); | ||
| free(controllers); | ||
| return 0; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,3 +73,24 @@ PS3EYEDriver | |
| PSEye userspace driver based on libusb + the Linux driver | ||
| by Eugene Zatepyakin, modified by Thomas Perl | ||
| from https://github.com/thp/PS3EYEDriver | ||
|
|
||
| pthreads-w32 | ||
| ============ | ||
|
|
||
| A Windows implementation of posix-threads. | ||
| https://www.sourceware.org/pthreads-win32/ | ||
|
|
||
| msvc-support | ||
| ============ | ||
|
|
||
| Work-arounds for MSVC's non-compliant C and a few unix-like libraries. | ||
| These were taken from various sources. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please specify these "various sources".
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also need license information here. |
||
|
|
||
| unistd.h is from http://stackoverflow.com/questions/341817/is-there-a-replacement-for-unistd-h-for-windows-visual-c | ||
| There is no license. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there would be no license, we wouldn't be allowed to include it. For stackoverflow, generally this applies: Please spend some time figuring out from where the code came from and specify the license that applies or rewrite that part from scratch; we can't accept code without a license. |
||
|
|
||
| stdint.h is from http://snipplr.com/view.php?codeview&id=18199 | ||
| and is public domain. | ||
|
|
||
| getopt.h is from https://gist.github.com/ashelly/7776712 | ||
| and uses the LGPL. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "...uses the LGPL 2.1 (or later)". |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line instead of commenting it out.