PSVRTracker icon indicating copy to clipboard operation
PSVRTracker copied to clipboard

Using ps3eyedevice in test_camera

Open opendata26 opened this issue 6 years ago • 5 comments

I have head a look into it but it seems if I did it the way it was done for ps3eyevideocapture there would be a lot of duplicated code, is this still how it should be done though?

opendata26 avatar Oct 21 '18 08:10 opendata26

Sorry for my slow reply on this and sorry I wasn't very clear on the refactor I had in mind. So the change I have in mind would throw out ps3eyevideocapture and use PS3EyeVideoDevice directly.

  1. Spawn instances of PS3EyeVideoDevice directly (instead of PS3EyeVideoCapture) here: https://github.com/HipsterSloth/PSVRTracker/blob/master/src/tests/test_camera.cpp#L53
  • This will also require use of the TrackerUSBDeviceEnumerator(PS3EYE) iterator https://github.com/HipsterSloth/PSVRTracker/blob/master/src/psvrservice/Device/Enumerator/TrackerUSBDeviceEnumerator.h#L15
  1. Convert the video feed property setting from the opencv interface: https://github.com/HipsterSloth/PSVRTracker/blob/master/src/tests/test_camera.cpp#L246-L290
  • To use the PS3EyeVideo functions: https://github.com/HipsterSloth/PSVRTracker/blob/master/src/psvrservice/PSVRTracker/PS3EyeVideo.h#L153-L164
  1. Switch setting the video mode from setting the width and fps properties: https://github.com/HipsterSloth/PSVRTracker/blob/master/src/tests/test_camera.cpp#L293-L305
  • To using PS3EyeVideoDevice::open() with the desired ePS3EyeVideoMode: https://github.com/HipsterSloth/PSVRTracker/blob/master/src/psvrservice/PSVRTracker/PS3EyeVideo.h#L142
  1. Switch the video frame polling from the opencv style overloaded operator >> style read: https://github.com/HipsterSloth/PSVRTracker/blob/master/src/tests/test_camera.cpp#L93-L94
  • To using the notifyFrameReceived callback passed into PS3VideoDevice::open() https://github.com/HipsterSloth/PSVRTracker/blob/master/src/psvrservice/Device/Interface/DeviceInterface.h#L143

  • That callback will give you a raw unsigned char * to the video frame. You can convert that to an cv::Mat using the cv::Mat raw pointer constructor. Example of that here:

https://github.com/HipsterSloth/PSVRTracker/blob/master/src/psvrservice/Device/View/ServerTrackerView.cpp#L297

  • The resulting cv::Mat can be passed to cv::imshow() as before (to actually render the buffer to the given named window).

https://github.com/HipsterSloth/PSVRTracker/blob/master/src/tests/test_camera.cpp#L98

Let me know if you have any questions with that. As you can tell, it's a pretty sizable refactor, but it should also help delete a bunch of old code.

HipsterSloth avatar Oct 23 '18 05:10 HipsterSloth

Ah, how would I access the PS3EyeVideoDevice and usbenumerator APIs though? Should I just duplicate the needed code into test_camera?

opendata26 avatar Oct 23 '18 09:10 opendata26

Sort of. You'll want to update the tests/CMakeLists.txt file to include the needed usbenumerator files in the autogenerated test_camera project:

https://github.com/HipsterSloth/PSVRTracker/blob/master/src/tests/CMakeLists.txt#L22-L29

This doesn't duplicate the files, but does re-build them in another project. At some point I want to refactor this so that the test_camera project links against the PSVRService_static library instead, but that can come later.

HipsterSloth avatar Oct 24 '18 06:10 HipsterSloth

Right, that makes sense now.

opendata26 avatar Oct 24 '18 10:10 opendata26

Hey everyone! Are you a codeveloper @opendata26?

I want to involve myself before long. My PSVR is being serviced right now, which has set me back a couple weeks to finding my way here. @HipsterSloth, that list looks like an awful lot. I hope looks are deceiving. I've put some code up here (https://github.com/dylanmckay/psvr-protocol/issues/14) that Trinus PSVR is looking at implementing right now...

Please give it a look if better approximating the view vector without tracking can assist the camera's worldview.

I want to help with tweaking until the experience is best... mainly I would like to help with solving for the best configuration; the stuff that comes after the headlight profiles are handed off from the imaging component.

m-7761 avatar Nov 07 '18 02:11 m-7761