inspirit / PS3EYEDriver

PS3EYE Camera Driver for OSX and Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trouble pulling frames from camera (update: Using libusb-win32 driver resolved issue)

jdrgoldeneagle opened this issue · comments

I don't know if this is necessarily an "issue" per se, and could possibly be something to do with my system, but I'm hoping someone can help explain what's going on and point me in the right direction.

I'm using Windows 10 and MSVC Express 2013, compiling for x64. When I first attempted to run the SDL example, it just hung. Long story short, after a lot of messing around with drivers and the PS3EyeDriver code, I've ended up with this result.

For some reason, the UVC header has the UVC_STREAM_ERR flag set, which was initially causing it to drop all the data (and just sit there waiting for frames that never come). When I disabled the test for that, I confirmed that I actually am receiving good image data, but for some reason I'm not receiving all of it (only about the first TRANSFER_SIZE*NUM_TRANSFERS bytes of data from what I can tell). If I increase the TRANSFER_SIZE, I receive more data (although past a certain point it seems to lock up). It seems that data is being lost somewhere, but with my very limited knowledge of libusb I'm not sure where to look to see if it's a problem with the libusb interface, buffer sizes, buffer queues, or some problem with the WinUSB driver being used for the camera. I haven't seen any reports of anyone else having problems like this, so there's a good chance that it's something with my system, but I don't understand how it works at all in that case.

I've attached this image showing what I'm receiving (with TRANSFER_SIZE set to 16384*16 so I get more than just a sliver). The upper half seems to update at full speed, the lower half kind of intermittently/flickers, and of course the bottom pink part is never getting filled in at all.
Partial Image from Buffer

I'd greatly appreciate any tips you can give me!

Hmm, interesting.

I've seen something similar to this on my machine. That turned out to be caused by a separate process also reading from the same camera (I had the SDL example still running in the background). I guess that's not the case for you, but might be worth verifying.

If you only seem to be receiving the first TRANSFER_SIZE*NUM_TRANSFERS, then it sounds like somehow the libusb transfers are not getting requeued in time. What's supposed to happen with a transfer is something like the following:

  1. The transfer is initially started with TRANSFER_SIZE (currently 16384 bytes) of data (see here)
  2. Once the transfer completes, the transfer_completed_callback is invoked at which point the transfer is processed
  3. Once the transfer is processed it is immediately resubmitted

Currently there are 8 transfers running concurrently in order to keep the bus busy. It sounds like some of the transfers are skipping step 3 (ie. not being resubmitted). That could be caused by the error condition being triggered, but I've personally never seen that happen during normal operation. Can you see if that ever occurs for you?

The code is liberally sprinkled with debug messages everywhere; can you try enabling it to see if any of those debug messages spit out anything useful?

Something you can also try is to install this USB software analyzer (there is a free trial). After installing, right-click on the camera in the list of devices, click Start Monitoring and select Statistics from the dialog. Then run the SDL example. If you're running at 640x480@60, it should hold steady at around ~36 MB/s. Something like this:

after_usb

Additionally, there have been some reports from users having problems with the camera when there are multiple devices attached to the same USB controller (especially things like bluetooth dongles). If this is also the case for you, you could try connecting the camera to a single controller with nothing else on it to see if that fixes anything.

You mention that you're using the WinUSB driver, which I'm not sure is correct. Personally I've only ever used it with the libusb driver installed on the device (I wasn't even aware that it would work at all without that). Can you try that and see if that fixes anything? There's some instruction on how to set it up here.

Finally, there are some troubleshooting instructions here that you might try.

Thank you so much! It was the WinUSB driver causing the problem (and also the libusbK driver), whatever it is. Works fine with the libusb-win32 driver (which I hadn't actually tried because during my research I had somehow got the impression that libusb-win32 was outdated and that WinUSB or libusbK was the way to go). Everything looks great now!

Hmm, so, I just got a Win10 machine myself and I'm seeing the same issues you were seeing, except I am using the libusb-win32 driver. Was there anything else that you needed to do to get it to work?

No, all I did was add "DEBUG" to the MSVC preprocessor macros, see if any of the debug messages did anything (I'd actually been going around converting some of them to printf's because I didn't know why they weren't showing anything and didn't think about it too hard), which didn't reveal anything useful. Then I used usbdeview to uninstall it, then put it back (it just reloaded the WinUSB driver anyway), then used Zadig to install the libusb-win32 driver. It seems to have been working fine since then, although a few minutes ago I unplugged it and used a different camera for a little while and when I came back to the PS3Eye it started crashing on me. I unplugged it and plugged it back in, checked that it was still showing ilbusb-win32 as the driver, and it seems to be working correctly again now.