Using two Ps3Eye cams with OpenCvSharp inside Unity3d
Posted: 26 February 2013 10:29 AM   [ Ignore ]
New Member
Rank
Total Posts:  6
Joined  2011-09-07

Hello

I’m new to the forum and no hawk at programming, especially once I step outside of my comfort zone (game programming using java or C# in Unity3d), so bear with me smile

So I’m doing a master thesis at my university on crowd gaming, using image processing to detect a crowd of kids holding and moving various colored glowsticks.
I’m using OpenCvSharp (https://code.google.com/p/opencvsharp/) since it’s compatible with the Unity3d game engine which I usually do games in.

I have basic video input, colorspace conversion and segmentation working, and now I would really like to add another camera, to get a “wider view” of the crowd. This is where I run into trouble.
I have connected two Ps3eye cameras to my computer, bought a “2 piece CL Eye pack” and activated both cameras, (screenshot from the CL-Eye Device Manager are attached), I also downloaded and installed the latest driver and SDK.
The two cameras work individually of eachother, however CL-Eye Test only shows one of them for video, both of them for audio (screenshot attached).

Now inside Unity, I have get the live videofeed using the OpenCV(sharp) call capture = Cv.CreateCameraCapture(x);, however no matter what parameter x i feed the function, I always get video from the same camera…
I tried using the index for my laptops inbuild camera and simultaneously another capture call, with index to a ps3eye camera, and that works, which leads me to believe that it is not a problem with OpenCvSharp as such, but more likely somewhere in the drivers…
How the h…. do I get video from both Ps3Eye cams simultaneously, using the two CvCreateCameraCapture() calls?

Specs are:
Windows 8 64x
Intel corei7-3632QM CPU @ 2,2 ghz
8 gb ram
Unity pro 4.0.0f
OpenCvSharp unity example from: http://ux.getuploader.com/aimino/download/3/CSharpTest_Win.zip

Image Attachments
Activated.pngCL-Eye-test.png
Profile
 
 
Posted: 26 February 2013 12:23 PM   [ Ignore ]   [ # 1 ]
New Member
Rank
Total Posts:  6
Joined  2011-09-07

And the code for image processing running in unity3D:

using UnityEngine;
using System.Collections;
using OpenCvSharp;
using System.Runtime.InteropServices; 


const int CAPTURE_WIDTH = 640;
const int CAPTURE_HEIGHT = 480;

private CvCapture capture;
private CvCapture capture2;
 
private IplImage input;
private IplImage input2;

// Use this for initialization  
void Start () {
      capture = Cv.CreateCameraCapture(1);
  capture2 = Cv.CreateCameraCapture(2);
      Cv.SetCaptureProperty(capture, CaptureProperty.FrameWidth, CAPTURE_WIDTH);
      Cv.SetCaptureProperty(capture, CaptureProperty.FrameHeight, CAPTURE_HEIGHT);
  Cv.SetCaptureProperty(capture2, CaptureProperty.FrameWidth, CAPTURE_WIDTH);
      Cv.SetCaptureProperty(capture2, CaptureProperty.FrameHeight, CAPTURE_HEIGHT);
   
      //Create image containers
      input = Cv.QueryFrame(capture);
      input2 = Cv.QueryFrame(capture2);
     
      Cv.NamedWindow(“InputStream”, WindowMode.AutoSize);
          Cv.NamedWindow(“InputStream2”, WindowMode.AutoSize);
  }
 
  // Update is called once per frame
  void Update () {
     
      //grab the capture data
      input = Cv.QueryFrame(capture);
      input2 = Cv.QueryFrame(capture2);
     
      Cv.ShowImage(“InputStream”, input);
      Cv.ShowImage(“InputStream2”, input2);

  }
 
      void OnDestroy()
        {
      Cv.DestroyAllWindows();
      Cv.ReleaseCapture(capture);
  }
}

Profile
 
 
Posted: 27 February 2013 08:07 PM   [ Ignore ]   [ # 2 ]
Administrator
Avatar
RankRankRankRank
Total Posts:  585
Joined  2009-09-17

Thank you for using our CL-Eye camera driver. To get access to more than one camera please use out CL-Eye SDK. Also install the code samples and look at the code that allows you to access cameras via SDK in C#.

tommyph - 26 February 2013 10:29 AM

Hello

I’m new to the forum and no hawk at programming, especially once I step outside of my comfort zone (game programming using java or C# in Unity3d), so bear with me smile

So I’m doing a master thesis at my university on crowd gaming, using image processing to detect a crowd of kids holding and moving various colored glowsticks.
I’m using OpenCvSharp (https://code.google.com/p/opencvsharp/) since it’s compatible with the Unity3d game engine which I usually do games in.

I have basic video input, colorspace conversion and segmentation working, and now I would really like to add another camera, to get a “wider view” of the crowd. This is where I run into trouble.
I have connected two Ps3eye cameras to my computer, bought a “2 piece CL Eye pack” and activated both cameras, (screenshot from the CL-Eye Device Manager are attached), I also downloaded and installed the latest driver and SDK.
The two cameras work individually of eachother, however CL-Eye Test only shows one of them for video, both of them for audio (screenshot attached).

Now inside Unity, I have get the live videofeed using the OpenCV(sharp) call capture = Cv.CreateCameraCapture(x);, however no matter what parameter x i feed the function, I always get video from the same camera…
I tried using the index for my laptops inbuild camera and simultaneously another capture call, with index to a ps3eye camera, and that works, which leads me to believe that it is not a problem with OpenCvSharp as such, but more likely somewhere in the drivers…
How the h…. do I get video from both Ps3Eye cams simultaneously, using the two CvCreateCameraCapture() calls?

Specs are:
Windows 8 64x
Intel corei7-3632QM CPU @ 2,2 ghz
8 gb ram
Unity pro 4.0.0f
OpenCvSharp unity example from: http://ux.getuploader.com/aimino/download/3/CSharpTest_Win.zip

Profile
 
 
Posted: 27 February 2013 11:19 PM   [ Ignore ]   [ # 3 ]
New Member
Rank
Total Posts:  6
Joined  2011-09-07

Hi, thanks for answering, I was hoping to catch your attention, seems like you helped alot of people on here smile

I already installed the SDK (should I chose Development, or Redistributeable binaries? - as I said I bought a 2 piece pack and activated two cameras) - Shouldn’t that, for starters, allow me to connect to both cameras (one at a time of course) in the CL-Eye Test app?

Profile
 
 
Posted: 01 May 2013 07:43 PM   [ Ignore ]   [ # 4 ]
New Member
Rank
Total Posts:  2
Joined  2013-05-01

Hi, I’ve just found this thread refering to the same issue I’m interested in, using 2 ps3 eyes in Unity 3D.
I’d like to know whether tommyph’s problem is solved or not before I devote myself into this issue.
Thanks in advance for any responce.

Profile
 
 
Posted: 02 May 2013 12:22 PM   [ Ignore ]   [ # 5 ]
New Member
Rank
Total Posts:  6
Joined  2011-09-07
近藤 直樹 - 01 May 2013 07:43 PM

Hi, I’ve just found this thread refering to the same issue I’m interested in, using 2 ps3 eyes in Unity 3D.
I’d like to know whether tommyph’s problem is solved or not before I devote myself into this issue.
Thanks in advance for any responce.

Hi

I did not solve this issue no… Instead I went on to work in C++ instead, with the intent to send data from that application to Unity using some socket programming… I’m having issues in C++ too, as you will notice from this thread:
http://codelaboratories.com/forums/viewthread/1073/

Profile
 
 
Posted: 02 May 2013 04:01 PM   [ Ignore ]   [ # 6 ]
New Member
Rank
Total Posts:  2
Joined  2013-05-01

Hi tommyph, thanks for quick reply and information on your efforts in C++.
Sad to speak, but it seems this issue is beyond my programming abilities.
Hope you’ll reach to your solution soon and also, I hope experts in Code Laboratories pay a little more attention on this
since I think there is a growing demand for stereoscopic camera integration with 3D engines like Unity, caused by
the successful launch of Oculus Rift. ## Maybe II DUO is ideal for the hardware…

Thanks again, Naoki

Profile
 
 
 
 


RSS 2.0     Atom Feed