openpnp / openpnp-capture

A cross platform video capture library with a focus on machine vision.
MIT License
129 stars 56 forks source link

High resolution MJPEG on 8MP camera fails with 0x80004005 "Unspecified error" #10

Closed trcwm closed 3 years ago

trcwm commented 7 years ago

High resolution MPJEG on 8MP camera fails with 0x80004005 "Unspecified error":

C:\Users\RB\Downloads>openpnp-capture-test.exe 0 3
==============================
 OpenPNP Capture Test Program
 Win 64 bit debug v0.01 Aug 15 2017
==============================
[DBG ] Context created
[DBG ] Enumerating devices
[DBG ] ICreateDevEnum created
[INFO]      -> PATH \\?\usb#vid_05a3&pid_8830&mi_00#6&27d2624d&0&0000#{65e8773d-
8f56-11d0-a3b9-00a0c9223196}\global
[DBG ] enumerateFrameInfo() called
[INFO] Capture pin found!
[INFO] Stream has 40 capabilities.
[INFO] 1600 x 1200  15 fps  24 bpp FOURCC=MJPG
[INFO] 3264 x 2448  15 fps  24 bpp FOURCC=MJPG
[INFO] 2592 x 1944  15 fps  24 bpp FOURCC=MJPG
[INFO] 2048 x 1536  15 fps  24 bpp FOURCC=MJPG
[INFO] 1280 x 960  15 fps  24 bpp FOURCC=MJPG
[INFO] 1024 x 768  30 fps  24 bpp FOURCC=MJPG
[INFO] 800 x 600  30 fps  24 bpp FOURCC=MJPG
[INFO] 640 x 480  30 fps  24 bpp FOURCC=MJPG
[INFO] 320 x 240  30 fps  24 bpp FOURCC=MJPG
[INFO] 1600 x 1200  15 fps  24 bpp FOURCC=MJPG
[INFO] 1600 x 1200  10 fps  16 bpp FOURCC=YUY2
[INFO] 3264 x 2448  2 fps  16 bpp FOURCC=YUY2
[INFO] 2592 x 1944  3 fps  16 bpp FOURCC=YUY2
[INFO] 2048 x 1536  3 fps  16 bpp FOURCC=YUY2
[INFO] 1280 x 960  10 fps  16 bpp FOURCC=YUY2
[INFO] 1024 x 768  10 fps  16 bpp FOURCC=YUY2
[INFO] 800 x 600  30 fps  16 bpp FOURCC=YUY2
[INFO] 640 x 480  30 fps  16 bpp FOURCC=YUY2
[INFO] 320 x 240  30 fps  16 bpp FOURCC=YUY2
[INFO] 1600 x 1200  10 fps  16 bpp FOURCC=YUY2
[INFO] ID 0 -> HD USB Camera
Number of devices: 1
ID 0 -> HD USB Camera
Unique:  HD USB Camera \\?\usb#vid_05a3&pid_8830&mi_00#6&27d2624d&0&0000#{65e877
3d-8f56-11d0-a3b9-00a0c9223196}\global
  Number of formats: 20
  Format ID 0: 1600 x 1200 pixels  FOURCC=MJPG
  Format ID 1: 3264 x 2448 pixels  FOURCC=MJPG
  Format ID 2: 2592 x 1944 pixels  FOURCC=MJPG
  Format ID 3: 2048 x 1536 pixels  FOURCC=MJPG
  Format ID 4: 1280 x 960 pixels  FOURCC=MJPG
  Format ID 5: 1024 x 768 pixels  FOURCC=MJPG
  Format ID 6: 800 x 600 pixels  FOURCC=MJPG
  Format ID 7: 640 x 480 pixels  FOURCC=MJPG
  Format ID 8: 320 x 240 pixels  FOURCC=MJPG
  Format ID 9: 1600 x 1200 pixels  FOURCC=MJPG
  Format ID 10: 1600 x 1200 pixels  FOURCC=YUY2
  Format ID 11: 3264 x 2448 pixels  FOURCC=YUY2
  Format ID 12: 2592 x 1944 pixels  FOURCC=YUY2
  Format ID 13: 2048 x 1536 pixels  FOURCC=YUY2
  Format ID 14: 1280 x 960 pixels  FOURCC=YUY2
  Format ID 15: 1024 x 768 pixels  FOURCC=YUY2
  Format ID 16: 800 x 600 pixels  FOURCC=YUY2
  Format ID 17: 640 x 480 pixels  FOURCC=YUY2
  Format ID 18: 320 x 240 pixels  FOURCC=YUY2
  Format ID 19: 1600 x 1200 pixels  FOURCC=YUY2
[DBG ] PlatformStream::open() reveals 40 stream capabilities
[INFO] Capture format set!
[INFO] Could not get exposure range information
[INFO] Could not get focus range information
[INFO] Could not get Zoom range information
[INFO] Width = 2048, Height = 1536
[INFO] Stream to device HD USB Camera opened
[DBG ] FOURCC = RGB
Stream ID = 0
Stream is open
=== KEY MAPPINGS ===
Press q to exit.
Press + or - to change the exposure.
Press f or g to change the focus.
Press z or x to change the zoom.
Press a or s to change the gain.
Press [ or ] to change the white balance.
Press p to estimate the actual frame rate.
Press w to write the current frame to a PPM file.
Set exposure to -7
Could not get focus limits.
Could not get zoom limits.
Set white balance to 4650
Set gain to 0 (min=0 max=100)
Estimating frame rate..
Frames = 37
Measured fps=18.50
Estimating frame rate..
Frames = 37
Measured fps=18.50
Estimating frame rate..
Frames = 37
Measured fps=18.50
[INFO] closing stream
[INFO] Callback counter = 3210
[DBG ] Stream::~Stream reports 3210 frames captured.
[DBG ] Context destroyed

C:\Users\RB\Downloads>openpnp-capture-test.exe 0 1
==============================
 OpenPNP Capture Test Program
 Win 64 bit debug v0.01 Aug 15 2017
==============================
[DBG ] Context created
[DBG ] Enumerating devices
[DBG ] ICreateDevEnum created
[INFO]      -> PATH \\?\usb#vid_05a3&pid_8830&mi_00#6&27d2624d&0&0000#{65e8773d-
8f56-11d0-a3b9-00a0c9223196}\global
[DBG ] enumerateFrameInfo() called
[INFO] Capture pin found!
[INFO] Stream has 40 capabilities.
[INFO] 1600 x 1200  15 fps  24 bpp FOURCC=MJPG
[INFO] 3264 x 2448  15 fps  24 bpp FOURCC=MJPG
[INFO] 2592 x 1944  15 fps  24 bpp FOURCC=MJPG
[INFO] 2048 x 1536  15 fps  24 bpp FOURCC=MJPG
[INFO] 1280 x 960  15 fps  24 bpp FOURCC=MJPG
[INFO] 1024 x 768  30 fps  24 bpp FOURCC=MJPG
[INFO] 800 x 600  30 fps  24 bpp FOURCC=MJPG
[INFO] 640 x 480  30 fps  24 bpp FOURCC=MJPG
[INFO] 320 x 240  30 fps  24 bpp FOURCC=MJPG
[INFO] 1600 x 1200  15 fps  24 bpp FOURCC=MJPG
[INFO] 1600 x 1200  10 fps  16 bpp FOURCC=YUY2
[INFO] 3264 x 2448  2 fps  16 bpp FOURCC=YUY2
[INFO] 2592 x 1944  3 fps  16 bpp FOURCC=YUY2
[INFO] 2048 x 1536  3 fps  16 bpp FOURCC=YUY2
[INFO] 1280 x 960  10 fps  16 bpp FOURCC=YUY2
[INFO] 1024 x 768  10 fps  16 bpp FOURCC=YUY2
[INFO] 800 x 600  30 fps  16 bpp FOURCC=YUY2
[INFO] 640 x 480  30 fps  16 bpp FOURCC=YUY2
[INFO] 320 x 240  30 fps  16 bpp FOURCC=YUY2
[INFO] 1600 x 1200  10 fps  16 bpp FOURCC=YUY2
[INFO] ID 0 -> HD USB Camera
Number of devices: 1
ID 0 -> HD USB Camera
Unique:  HD USB Camera \\?\usb#vid_05a3&pid_8830&mi_00#6&27d2624d&0&0000#{65e877
3d-8f56-11d0-a3b9-00a0c9223196}\global
  Number of formats: 20
  Format ID 0: 1600 x 1200 pixels  FOURCC=MJPG
  Format ID 1: 3264 x 2448 pixels  FOURCC=MJPG
  Format ID 2: 2592 x 1944 pixels  FOURCC=MJPG
  Format ID 3: 2048 x 1536 pixels  FOURCC=MJPG
  Format ID 4: 1280 x 960 pixels  FOURCC=MJPG
  Format ID 5: 1024 x 768 pixels  FOURCC=MJPG
  Format ID 6: 800 x 600 pixels  FOURCC=MJPG
  Format ID 7: 640 x 480 pixels  FOURCC=MJPG
  Format ID 8: 320 x 240 pixels  FOURCC=MJPG
  Format ID 9: 1600 x 1200 pixels  FOURCC=MJPG
  Format ID 10: 1600 x 1200 pixels  FOURCC=YUY2
  Format ID 11: 3264 x 2448 pixels  FOURCC=YUY2
  Format ID 12: 2592 x 1944 pixels  FOURCC=YUY2
  Format ID 13: 2048 x 1536 pixels  FOURCC=YUY2
  Format ID 14: 1280 x 960 pixels  FOURCC=YUY2
  Format ID 15: 1024 x 768 pixels  FOURCC=YUY2
  Format ID 16: 800 x 600 pixels  FOURCC=YUY2
  Format ID 17: 640 x 480 pixels  FOURCC=YUY2
  Format ID 18: 320 x 240 pixels  FOURCC=YUY2
  Format ID 19: 1600 x 1200 pixels  FOURCC=YUY2
[DBG ] PlatformStream::open() reveals 40 stream capabilities
[INFO] Capture format set!
[INFO] Could not get exposure range information
[INFO] Could not get focus range information
[INFO] Could not get Zoom range information
[ERR ] Error calling RenderStream (HRESULT=80004005)
[ERR ] Could not open stream for device HD USB Camera
Stream ID = -1
[ERR ] isOpenStream was called with a negative stream ID
Stream is closed (?)
[DBG ] Context destroyed
vonnieda commented 7 years ago

@trcwm Is this still happening, or can we close this?

trcwm commented 7 years ago

I'm unable to reproduce/debug this error as I don't have such a camera. The code hasn't changed, so this behaviour should still be there.

vonnieda commented 7 years ago

@trcwm Ah, okay. Did someone else originally report this? Do you know who? I'd like to follow up on it so we can close this.

trcwm commented 7 years ago

@vonnieda Yes, @kakemoms reported it.

kakemoms commented 6 years ago

Sorry, my OpenPNP had a vacation.. Anyway, I can set property "CAP_PROP_FOURCC" under Camera specific now. I set it to "MJPG" and for some reason it gets changed to "0.0", but except for that it works for 2592x1944 at 15fps (which I have to enter as 1944 width and 2592 height as I have a rotated screen). Please note that if I put in 2592 width and 1944 height, I get 3fps and YUY2, but correct resolution.. PS: Entering 2448 width and 3264 height freezes OpenPNP image, while 3264 width and 2448 heigh gives correct resolution, but at a dreaded 2fps...

trcwm commented 6 years ago

@kakemoms the camera library does not now you have a rotated screen and only accepts the resolutions as reported by the camera. I suspect that entering 2448 x 3264 will result in the library being unable to find the requested format and simply not creating a capture stream.

I'm not sure why you get a 2fps YUY2 stream when requesting MJPEG. That should not happen.

kakemoms commented 6 years ago

Ok. Well.. still, its strange that 3264 x 2448 works (as YUY2) if its not in the library.

Another thing is that the pixels per mm (or was it mm per pixel) seems to be way off. Entering it manually was the only way to get it working (and a slight change of the values result in exaggerated movement).

Since it worked before I started changing resolution, its probably related.

trcwm commented 6 years ago

3264 x 2448 is reported by the library, 2448 x 3264 is not.

kakemoms commented 6 years ago

But 1944 x 2592 works, so its kind of inconsistent..