Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
449 changes: 300 additions & 149 deletions CMakeLists.txt

Large diffs are not rendered by default.

File renamed without changes.
76 changes: 76 additions & 0 deletions README.win64_mingw64
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
68 changes: 68 additions & 0 deletions README.win64_msvc2013
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
56 changes: 56 additions & 0 deletions WINDOWS_EXTRA
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.
2 changes: 1 addition & 1 deletion examples/c/battery_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main(int argc, char* argv[])
if(buttons & Btn_PS)
running = false;
}
sleep(1);
usleep(1000000);
}

for(i=0; i<c; i++) {
Expand Down
4 changes: 3 additions & 1 deletion examples/c/test_record_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@

int main(int arg, char** args) {
int count = psmove_count_connected();
PSMove *moves[count];
//PSMove *moves[count];
Copy link
Copy Markdown
Owner

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.

PSMove **moves = (PSMove **)calloc(count, sizeof(PSMove *));

int i;
void *frame;
Expand Down Expand Up @@ -91,6 +92,7 @@ int main(int arg, char** args) {
}

psmove_tracker_free(tracker);
free(moves);
return 0;
}

26 changes: 15 additions & 11 deletions examples/c/test_roi_size.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,17 @@ save(int i, int roi_size, struct TestContext *context)
cvSaveImage(path, frame, imgParams);
}

#define cROIS 3
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Named constant macros should be all-uppercase, maybe use ROI_COUNT?

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.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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:
Expand All @@ -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.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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);
Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand Down
5 changes: 4 additions & 1 deletion examples/c/test_tracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@
int main(int arg, char** args) {
int i;
int count = psmove_count_connected();
PSMove* controllers[count];
//PSMove* controllers[count];
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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;

Expand Down Expand Up @@ -111,6 +113,7 @@ int main(int arg, char** args) {
}

psmove_tracker_free(tracker);
free(controllers);
return 0;
}

21 changes: 21 additions & 0 deletions external/README
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify these "various sources".

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The 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: user contributions licensed under cc by-sa 3.0 with attribution required

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.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"...uses the LGPL 2.1 (or later)".

Loading