The PS3Eye Multicam Driver is here!!!

Finally, here is the long awaited PS3Eye multicam driver

After a lot of testing and optimization of the internal driver code, I finally am ready to release the first version of the PS3Eye multicam driver.
For your reference, below is the diagram of the internal components of the driver. For a single camera configuration the ‘Image Stitching’ component is bypassed.

The driver exports simple API that allows for full control of PS3Eye cameras.
I chose a C style export functions this time to allow for easier integration with different programming languages such as C#.
Here is the ‘PS3EyeMulticam.h’ file that you would normally include in your code:

////////////////////////////////////////////////////////////////////////////////////////////
//
// This library allows you to use multiple PS3Eye cameras in your own applications.
//
// For updates, more information and downloads visit: 
// http://www.alexpopovich.com or
// https://alexpopovich.wordpress.com/
//
// Copyright 2008,2009 (c) AlexP.  All rights reserved.
//
////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <windows .h>

#ifdef PS3EYEMULTICAM_EXPORTS
#define PS3EYEMULTICAM_API extern "C" __declspec(dllexport)
#else
#define PS3EYEMULTICAM_API extern "C" __declspec(dllimport)
#endif

////////////////////////////////////////////////////////////////////////////////////////////
// PS3EyeMulticam API
////////////////////////////////////////////////////////////////////////////////////////////

typedef enum{ QVGA, VGA }Resolution;

// Camera information
PS3EYEMULTICAM_API int PS3EyeMulticamGetCameraCount();

// Library initialization
PS3EYEMULTICAM_API bool PS3EyeMulticamOpen(int camCnt, Resolution res, int frameRate);
PS3EYEMULTICAM_API void PS3EyeMulticamClose();

// Capture control
PS3EYEMULTICAM_API bool PS3EyeMulticamStart();
PS3EYEMULTICAM_API void PS3EyeMulticamStop();

// Settings control
PS3EYEMULTICAM_API bool PS3EyeMulticamLoadSettings(char* fileName="settings.xml");
PS3EYEMULTICAM_API bool PS3EyeMulticamSaveSettings(char* fileName="settings.xml");
PS3EYEMULTICAM_API void PS3EyeMulticamShowSettings();

// Processed frame image data retrieval
PS3EYEMULTICAM_API bool PS3EyeMulticamGetFrameDimensions(int &width, int &height);
PS3EYEMULTICAM_API bool PS3EyeMulticamGetFrame(PBYTE pData, int waitTimeout=2000);

////////////////////////////////////////////////////////////////////////////////////////////

Included in the driver archive is a full source code of a simple ‘PS3EyeMulticamTest’ application that allows you to run and test the multicamera driver. This code could also serve as a good starting point for writing your own OpenCV image processing apps.
The PS3EyeMulticamTest app uses all of the API functions defined in ‘PS3EyeMulticam.h’ file.
Here is the ‘PS3EyeMulticamTest.cpp’ file:

//
// PS3EyeMulticamTest.cpp
//
// This is a quick test application for the 
// PS3EyeMulticam driver
//
// To build it, in VS2008 create en empty window app project
// and add all the files in this folder to it.
//
#include "stdafx.h"

#define WINDOW_NAME		"Capture Window"
bool bRunning = false;
int w, h;
 
// Capture thread
DWORD WINAPI Capture(LPVOID)
{
	IplImage *grayImage = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 1);
	PS3EyeMulticamStart();
	while(bRunning)
	{
		PBYTE pBuffer = NULL;
		cvGetImageRawData(grayImage, &pBuffer);
		PS3EyeMulticamGetFrame(pBuffer);
		cvShowImage(WINDOW_NAME, grayImage);
	}
	PS3EyeMulticamStop();
	cvReleaseImage(&grayImage);
	return 0;
}

void Program()
{
	// Query driver for number of connected PS3Eye cameras
	int camCnt = PS3EyeMulticamGetCameraCount();
	printf("Found %d PS3Eye cameras\n", camCnt);
	if(camCnt == 0)
	{
		MessageBox(NULL,"No PS3Eye camera(s) found","PS3EyeMulticamTest", MB_ICONEXCLAMATION);
		return;
	}
	// Open cameras
	if(!PS3EyeMulticamOpen(camCnt, VGA, 30))
	{
		MessageBox(NULL,"Could not open PS3Eye camera(s)","PS3EyeMulticamTest", MB_ICONEXCLAMATION);
		return;
	}
	// Load the default camera settings 'settings.xml' file
	// If the file is not found it will be created
	PS3EyeMulticamLoadSettings("settings.xml");

	// Get output image dimensions
	PS3EyeMulticamGetFrameDimensions(w, h);
	printf("Image dimensions (%d, %d)\n", w, h);

	// Create OpenCV main window
	cvNamedWindow(WINDOW_NAME, CV_WINDOW_AUTOSIZE);
	cvMoveWindow(WINDOW_NAME, 0, 0);
	cvResizeWindow(WINDOW_NAME, w, h);

	// Start PS3Eye image capture thread
	HANDLE hThread = CreateThread(NULL, 0, Capture, NULL, 0, 0);
	if(hThread == NULL)
	{
		MessageBox(NULL,"Could not create capture thread","PS3EyeMulticamTest", MB_ICONEXCLAMATION);
		PS3EyeMulticamClose();
		return;
	}
	bRunning = true;
	// The '<esc>' key will exit the program
	// The 's' key will open camera settings dialog
	while(bRunning)
	{
		int key = cvWaitKey(0);
		switch(key)
		{
			case 's':
			case 'S':
				// Display settings
				PS3EyeMulticamShowSettings();
			break;
			case 0x1b:
				printf("Exiting...\n");
				// Stop the capture thread
				bRunning = false;
				// Wait for thread to exit
				WaitForSingleObject(hThread, 3000);
				printf("Thread exited\n");
			break;		
		}
	}
	// Save camera settings
	printf("Saving settings\n");
	PS3EyeMulticamSaveSettings();
	printf("Closing OpenCV window\n");
	cvDestroyWindow(WINDOW_NAME);
	PS3EyeMulticamClose();
}

// This is the program entry if you link with /SUBSYSTEM:CONSOLE option
int main(int argc, char *argv[])
{
	Program();
	return 0;
}

// This is the program entry if you link with /SUBSYSTEM:WINDOWS option
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
	Program();
	return 0;
}

Last but not least, here you will find the PS3EyeMulticam.rar file.
Enjoy!

~Alex

~ by Alexander Popovich on September 4, 2009.

33 Responses to “The PS3Eye Multicam Driver is here!!!”

  1. Great work mate!!!

  2. First Alex thanks for the great works with the Ps3Eye drivers.
    Using the multicam driver at high speed with 2 cams
    in VGA at 60fps I get some intermittent blinking on each cameras,
    at 75 fps I got no image (i am using the return flag of PS3EyeMulticamGetFrame() ).

    could we have access to each camera in a separate call ?
    could you comment on these ?
    Thanks again

    • You’re welcome guys.

      @Maa
      There are two issues I see:

      1. Running two cameras at 60fps maxes out the USB 2.0 bandwidth. If your USB controller is used by any other device, you will see frames being dropped. Two cameras running @ 75fps will not run from a single USB controller. One way to go around this is to install second USB controller and use one camera on each.

      2. What is your CPU/RAM speed? And what is the CPU usage when running @ 60fps? Note that for this kind of high performance image processing, naturally you’ll need a fast CPU.

      Currently the way the driver is designed, there is only one stitched output image being output from the driver. You could use that image in your software by setting the stitching overlap to 0. Then you’ll have two camera images horizontally tiled. This is good because you can simultaneously process both camera images. One example could be a stereo vision application.

      ~Alex

      • hey alex i followed all of the steps on how to download the programs and the ps3 camera, i am running windows vista 32bit and im lost on how to use the ps3 program with touchlib. i dont understand how to use the code in touchlib to allow the ps3 camera to work in it

  3. wow, that’s really an excellent work!!! fantastic !!!

  4. Hi there is a way to use PS3 Eye Camera on PC with JAVA and JMF (Java Media Framework) ?

  5. Hi, there is a way to use PS3 Eye Camera with JAVA and JMF (Java media framework) ?

  6. Hi,

    Thanks for this driver. I´m using it in an application and I´m working with color images. How can I get color images from cameras?
    Thanks again

  7. can i use this on xb and would it work on aim?

  8. Hi Alex,

    I think you’re a god for many many DIY multitouch devs out there.
    But I got one question.

    2 camera’s gives you an awkward resolution of 1280×480.
    Will there be in the future be support for 4 or even 6 camera’s setup? So we could have resolutions like 1280×1440?

    But don’t worry about computer specs. If anyone wants that kind of setup. We could just as easily buy 4 pci express usb boards.

    Keep up the great great great work, and hopefully there will be future releases.

    Greets

  9. First of All I have to say brovo. This is amazing work and I just bookmarked all of this.

    Im looking into upgrading from my eyetoy to the playstation eye. My primary reasoning is that I run windows 7 64bit. My question is would it be hard to port your driver to use the eyetoy?

    My other question (which Im sorry if you have already stated) will this software work in things like MSN messenger. If so I’d be highly interested in upgrading to a playstation eye

  10. how do i record with ps3 eye i cant seem to get it to work with win avi video capture

  11. I don’t understand, The file and what not that I downloaded wasn’t recognized by windows

  12. so how does this install on xp64? this is bunk

  13. Hi, i would love to use the new multi cam driver in 960×640,
    but i guess this resulution is not yet supported. Do you plan on adding it?

    • Oliver,

      Thanks for your comment. I was actually planning on adding different camera orientation settings to the driver. This will include individual camera orientation (ie. horizontal/vertical) as well as their arrangement within the large frame (ie. 1:2/2:1/1:3/3:1/1:4/4:1/2:2 etc). 960×640 is definitely nice resolution and I like to support it. Will keep you posted about the progress on this.

      ~Alex

      • Hi Alex,
        just stumbled over your comment here. Is there any progress on that by now?
        Best wishes, Karl

  14. Hi Alex!

    we’re awating the new driver so eagerly!! We expect the 960×640 res to solve all the problems we are currently facing. Can you give a rough estimate on the release date?

    Best, Phil

  15. Alex
    thanks for that great work – well done! Do you have any references for using this cam and drivers for FreeTrack? You know, the head tracking software via IR. The high FPS rate makes this cam very interesting for that business. Sending in b/w would be fine, but I didn’t find any information about that yet.
    Does your driver run on Windows 7 x64? What do I have to do to bring that cam to life?
    Thanks in advance!

    Chris

    • Hey Chris, thanks for the feedback. The driver runs on Windows 7 x64. As far as tracking IR points, you could use my SDK and general image processing library such as OpenCV to accomplish this.

      ~Alex

  16. alex, is it possible to get color output in multi camera mode?

  17. Hi Alex,

    nice job with hacking the PS3 to work on Windows! I am trying to use the PS3 SDK for Computer Vision on a robot of mine, what will go to competition in a few days.

    I noticed that the AutoAEC() and SetExposure() calls of PS3 SDK have no effect! Is that so or am I doing it wrong?

    I also tried Multicam driver, but it seems that it works only in black-and-white mode.

    I need color vision and being able to set exposure. Can you help me with this?

    Thanks,
    R

    • Hi Ronald, Thanka for your feedback. Changing AutoAEC() and SetExposure() does have an effect but only after you start capturing video on the camera. In order to make it work try setting those values after you recieve one or a few frames from the camera. As an alternative you can setup a delay in your code after you start capturing. Then set the desired values and proceede to your frame capture/processing loop.

      ~Alex

  18. Hi Alex, Thanks for your amazing work. is it possible to capture videos from ps3 eyecam in color with multi camera application/driver?

    • Thanks for your feedback. This is among other things, one of the items on my list for the next version of the driver.

      ~Alex

  19. hey do someone nows wy it not works with windows live messager

  20. Alex, thank you for the great work, you deserve an award, or at least a chunk of money!

    I want to build an array of 4 cameras, 2 stereo instances. Assuming a machine has 2 USB 2.0 controllers, does the config file support this by adding entries to settings.xml?

    Can you provide any info on how to do this?

  21. woooooooooooooooooooooooooooothxxxxxxxxxxxxxxxxALEX!!!!
    I need it !
    HOOO!!

  22. Hey, i download your thing and after i bought a real webcam… I wanted to uninstall this and now, if i want to go on chats i cant and that tell me to download the latest version of your driver… The only place where i can go its on msn… How can i have my computer back ?

  23. can i use this with open broadcaster and stream a couple of cams? cause as u may know my second ps eye is not recognized at all. thanks in advance ( i hope i get notified)

  24. ?

  25. ??????????????????????????????????????????

Leave a reply to Alexander Popovich Cancel reply