Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uvc_start_streaming failed: -2 #27

Closed
kevinNew0809 opened this issue Apr 28, 2020 · 24 comments
Closed

uvc_start_streaming failed: -2 #27

kevinNew0809 opened this issue Apr 28, 2020 · 24 comments

Comments

@kevinNew0809
Copy link

hello,i'm the new user of purethermal
I just bought purethermal2 with flir lepton2.5 and I connected to raspberry Pi 4 model B via usb port
i have tried getthermal and it could work.
But then i try uvc-radiometry.py and got wrong:

device opened!
Version gpp: 1.0.32 dsp: 1.0.32
FLIR part #: b'500-0763-01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
FLIR serial #: b'@\xb0*\x00\x00\x00\x00\x00'
format: b'UYVY'
frame 80x60 @ 9fps
format: b'Y16 '
frame 80x60 @ 9fps
frame 80x63 @ 9fps
format: b'Y8 '
frame 80x60 @ 9fps
format: b'RGBP'
frame 80x60 @ 9fps
format: b'}\xeb6\xe4'
frame 80x60 @ 9fps
uvc_start_streaming failed: -2

I also tried uvc-deviceinfo.py and it could work
I had modified uvc_find_device function and it couldn't work either
libuvc.ucv_find_device(ctx, byref(dev), 0x1e4e, 0x0100,0)

Please help me figure out the wrong message!

@kekiefer
Copy link
Member

Hi, what PureThermal camera firmware do you have? RPi has a bug limiting usb iso bandwidth that we added a workaround starting with version 1.3.0.

@kevinNew0809
Copy link
Author

Thanks for reply, i didn't download purethermal1-firmware.
I just download Getthermal、purethermal1-uvc-capture、libuvc、libusb. Should I download purethermal1-firmware?

@kekiefer
Copy link
Member

The firmware is the code running on the PureThermal board itself. Instructions for updating this code are in the groupgets/purethermal1-firmware readme.

Since version 1.2.0, you can get the version number this way:

lsusb -d 1e4e:0100 -v | grep iProduct

The latest version is 1.3.0, which is the minimum required for raspberry pi.

@kevinNew0809
Copy link
Author

Thanks kekiefer for reply, I used the code and got reply below:
iProduct 2 PureThermal (fw:v1.3.0)

It seems that my firmware is the latest version but I still got error uvc_start_streaming failed: -2

@kekiefer
Copy link
Member

kekiefer commented May 4, 2020

OK, that's good. Another thought -- do you have a version of libuvc from your OS installed? You can try with the purethermal1-uvc-capture code on the branch master+libuvc-upstream. This will work with libuvc upstream: https://github.com/libuvc/libuvc (your OS version may be new enough, I don't know)

@UchiyKei1320
Copy link

Hi, I am having the same problem. In my environment, Getthermal worked, but when I try uvc-radiometry.py I get the same error, uvc_start_streaming failed: -2.
Did you solve this problem?
 

@vancanwin
Copy link

Ditto - same issue here. with the uvc_start_streaming failure: -2

@kekiefer
Copy link
Member

OK, that's good. Another thought -- do you have a version of libuvc from your OS installed? You can try with the purethermal1-uvc-capture code on the branch master+libuvc-upstream. This will work with libuvc upstream: https://github.com/libuvc/libuvc (your OS version may be new enough, I don't know)

Have you tried this?

@UchiyKei1320
Copy link

Thanks very much kekiefer for reply.
Yes, I tried installing libuvc.

I followed the steps below to install libuvc.

  1. sudo apt-get install libusb-1.0.0-dev (for installing libusb)
  2. git clone https://github.com/libuvc/libuvc
  3. cd libuvc
  4. mkdir build
  5. cd build
  6. cmake ..
  7. make && sudo make install

However, This problem has not been resolved.
Do you have any idea?

@kekiefer
Copy link
Member

Are you also using the master+libuvc-upstream branch of this code? Also, you might confirm that it is loading the libuvc you just installed by running like LD_DEBUG=libs python3 uvc-radiometry.py and look for the part where it loads libuvc.

@UchiyKei1320
Copy link

Thanks very much kekiefer for reply.
Yes, I followed the steps below to install master+libuvc-upstream.

  1. git clone https://github.com/groupgets/purethermal1-uvc-capture.git

Then, I executed command of LD_DEBUG=libs python3 uvc-radiometry.py in /purethermal1-ucv-capture/pyhon.
The results of that time are shown below.

...(Omitted because it is long)
2649: calling init: /usr/lib/python3.7/lib-dynload/_queue.cpython-37m-arm-linux-gnueabihf.so
2649:
unsupported descriptor subtype VS_COLORFORMAT
unsupported descriptor subtype VS_COLORFORMAT
unsupported descriptor subtype VS_COLORFORMAT
unsupported descriptor subtype VS_COLORFORMAT
unsupported descriptor subtype VS_COLORFORMAT
device opened!
Version gpp: 3.3.26 dsp: 3.3.26
FLIR part #: b'500-0771-01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
FLIR serial #: b'F\xe3*\x00\x00\x00\x00\x00'
format: b'UYVY'
frame 160x120 @ 9fps
format: b'Y16 '
frame 160x120 @ 9fps
frame 160x122 @ 9fps
format: b'Y8 '
frame 160x120 @ 9fps
format: b'RGBP'
frame 160x120 @ 9fps
format: b'}\xeb6\xe4'
frame 160x120 @ 9fps
uvc_start_streaming failed: -2
2649:
2649: calling fini: python3 [0]
2649:
2649:
2649: calling fini: /usr/lib/arm-linux-gnueabihf/libatomic.so.1 [0]
...(Omitted because it is long)

I am sorry to cause you inconvenience, but I am looking forward to your reply

@kekiefer
Copy link
Member

Did you run git checkout master+libuvc-upstream to use the correct branch?

What you posted is not useful. You're looking for the part in that output where it locates libuvc, to make sure it loads the one you built.

Also, verify your PT1 firmware version is 1.3.0 with the methods above, to make sure we're all on the same page.

@UchiyKei1320
Copy link

UchiyKei1320 commented Jun 26, 2020

Thanks very much kekiefer for reply.
I couldn't branch properly because I had little knowledge of git. I'm sorry.
I executed command of git checkout master+libuvc-upstream.
This problems solved and uvc-radiometry.py runned normaly after that.
I've been plagued with this problem for a long time and thanks to you I've been able to solve it.
Thank you very much for your time.

@kekiefer
Copy link
Member

Thanks for the input. I've created #34 to make this change the default.

@junartho
Copy link

junartho commented Sep 4, 2020

hi @kekiefer

i use jetson nano and PT with lepton 3.0
i have problem uvc_start_streaming failed: -2

i have run:
sudo apt-get install libusb-1.0.0-dev (for installing libusb)
git clone https://github.com/libuvc/libuvc
cd libuvc
mkdir build
cd build
cmake ..
make && sudo make install
git checkout master+libuvc-upstream

but the problem is still showing up. when i run LD_DEBUG=libs python3 uvc-radiometry.py

7837: calling init: /usr/lib/python3/dist-packages/numpy/random/mtrand.cpython-36m-aarch64-linux-gnu.so
7837:
Found 1 devices
device opened: b'GroupGets' b'PureThermal (fw:v1.3.0)' b'000f001b-5109-3538-3731-313200000000'
Version gpp: 3.1.51 dsp: 3.1.51
FLIR part #: b'500-0726-01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
FLIR serial #: b'c))\x00\x00\x00\x00\x00'
format: b'UYVY'
frame 160x120 @ 9fps
format: b'Y16 '
frame 160x120 @ 9fps
frame 160x122 @ 9fps
format: b'Y8 '
frame 160x120 @ 9fps
format: b'RGBP'
frame 160x120 @ 9fps
format: b'}\xeb6\xe4'
frame 160x120 @ 9fps
uvc_start_streaming failed: -2
7837:
7837: calling fini: python3 [0]

is there another command that i missed? im looking forward to hearing your solution. thank you

@kekiefer
Copy link
Member

kekiefer commented Sep 4, 2020

It looks like you have done everything right. I do not have this platform so I can't offer much beyond that. Make sure the device is not attached to a hub if you can avoid it, check for kernel error messages, and reach out to the vendor and ask them to fix their isochronous full-speed USB bandwidth limitations.

@adamczez
Copy link

adamczez commented Sep 6, 2020

Hi,

I have followed this recipe but despite it I have the same problem with uvc_start_streaming failed: -2.
I have PureThermal v2 with firmware iProduct 2 PureThermal (fw:v1.3.0) connected to raspberry Pi 2 and radiometric Lepton 3.5

Other program opencv-capture.py in ~/purethermal1-uvc-capture-master-libuvc-upstream/python works!

When I looked what -2 error means in libuvc it is UVC_ERROR_INVALID_PARAM = -2

Do we actually know what the problem is?

Seems that up to libuvc.uvc_start_streaming(devh, byref(ctrl), PTR_PY_FRAME_CALLBACK, None, 0) call everything works.

I will appreciate any pointers how to solve this.
Cheers
Adam

@adamczez
Copy link

adamczez commented Sep 6, 2020

Hi

I think I have found what the problems is. It is mismatch between format of the frame in the call to libuvc.uvc_start_streaming and the format specified libuvc.uvc_get_stream_ctrl_format_size just one line above.

In libuvc.uvc_get_stream_ctrl_format_size we have UVC_FRAME_FORMAT_Y16 and in the same call we call frame_formats[0]. However frame_formats[0] represent not format Y16 but format UYVY so when I have used this one instead of UVC_FRAME_FORMAT_Y16 uvc-radiometry.py started to work.

What this means is that we could leave UVC_FRAME_FORMAT_Y16 and use frame_formats[1] instead, but then with frame_format[1] two formats are reported :
format: b'Y16 '
frame 160x120 @ 9fps
frame 160x122 @ 9fps
I am not sure why and which one to use?

Cheers
Adam

@adamczez
Copy link

adamczez commented Sep 6, 2020

Hi,

if you look in libuvc_internal.h you will notice that Y16 is NOT UVC_FRAME_FORMAT_Y16 = 9 but should be 10.
Once you change UVC_FRAME_FORMAT_Y16 from 9 to 10 in uvctype.py, let alone uvc-radiometry.py will work it will also correctly read min and max temperatures.

Cheers
Adam

Important bit form libuvc_internal.h below

enum uvc_frame_format {
UVC_FRAME_FORMAT_UNKNOWN = 0,
/** Any supported format /
UVC_FRAME_FORMAT_ANY = 0,
UVC_FRAME_FORMAT_UNCOMPRESSED,
UVC_FRAME_FORMAT_COMPRESSED,
/
* YUYV/YUV2/YUV422: YUV encoding with one luminance value per pixel and

  • one UV (chrominance) pair for every two pixels.
    /
    UVC_FRAME_FORMAT_YUYV,
    UVC_FRAME_FORMAT_UYVY,
    /
    * 24-bit RGB /
    UVC_FRAME_FORMAT_RGB,
    UVC_FRAME_FORMAT_BGR,
    /
    * Motion-JPEG (or JPEG) encoded images /
    UVC_FRAME_FORMAT_MJPEG,
    UVC_FRAME_FORMAT_H264,
    /
    * Greyscale images /
    UVC_FRAME_FORMAT_GRAY8,
    UVC_FRAME_FORMAT_GRAY16,
    /
    Raw colour mosaic images /
    UVC_FRAME_FORMAT_BY8,
    UVC_FRAME_FORMAT_BA81,
    UVC_FRAME_FORMAT_SGRBG8,
    UVC_FRAME_FORMAT_SGBRG8,
    UVC_FRAME_FORMAT_SRGGB8,
    UVC_FRAME_FORMAT_SBGGR8,
    /
    * YUV420: NV12 /
    UVC_FRAME_FORMAT_NV12,
    /
    * Number of formats understood */
    UVC_FRAME_FORMAT_COUNT,
    };

@kekiefer
Copy link
Member

kekiefer commented Sep 6, 2020

Good find. We've been struggling with bandwidth problems for so long with the same error message that finding another cause for them never occurred to me.

I guess this is the problem with pointing to upstream code and doing the bindings like this. The commit libuvc/libuvc@53e2d2f came in and added a value in the middle of the enumeration which broke us.

kekiefer added a commit that referenced this issue Sep 6, 2020
Commit libuvc/libuvc@53e2d2f
added a value to the middle of the types enumeration, which broke
our bindings. This manifested as the "uvc_start_streaming failed: -2"
error.

This change corrects the enumeration value to match master.

Refs #27
@apolo74
Copy link

apolo74 commented Mar 31, 2021

Hi guys,
I just want to leave this note in here in case my experience can be useful for somebody else having these problems.
I'm working with an NVIDIA Jetson TX2 connected to ConnectTech Quasar board and the FLIR Lepton 3.5 is connected to the PureThermal v2 board which in turn is connected to one of the USB ports in the Quasar board.
Before working on the Jetson TX2 I wanted to test the PureThermal v2 on my laptop (running Ubuntu 18.04) and in there I only have some minor difficulties with the location of the libuvc.so library and the execution being SUDO but I managed to run all scripts in the end. So I thought I was ready to test everything on the Jetson TX2 without problems... naive me :)
I had tons of problems and tried to follow the instructions in this page but with no luck... then I went back to my Ubuntu installation and realized two important things:

  1. I was using the master repository of the purethermal1-uvc-capture and NOT the master+libuvc-upstream
  2. Inside the purethermal/python/uvctypes.py file on line 194, UVC_FRAME_FORMAT_Y16 = 13 so it's not equal to 10 as suggested previously. Once I changed the value back to 13 the 'uvc_start_streaming failed: -2' message disappeared and I was able to see the output of uvc-radiometry.py!!!
    I don't know why this is as it is and I hope the developers will be able to organized this information and I hope this idea can help others.
    Cheers,
    Boris

@kekiefer
Copy link
Member

kekiefer commented Mar 31, 2021

Thanks for the update! For anyone who comes across this -- that enumeration value needs to match with the value used in the libuvc you're loading. Note that with the code in master+libuvc-upstream (which will soon be merged into master, I guess, since no one has commented otherwise) you should not be using the groupgets fork of libuvc, but the upstream repo -- and in the latest libuvc the value of Y16 as 10 is correct: https://github.com/libuvc/libuvc/blob/master/include/libuvc/libuvc.h#L78

@Dineshkumar-code
Copy link

Dineshkumar-code commented Apr 10, 2021

for linux user's
try this
kindly go to uvctypes.py to change the cdll.LoadLibrary("libuvc.so") to change path cdll.LoadLibrary("/usr/local/lib/libuvc.so")

@billhung
Copy link

Hi @kekiefer

We got the exact same error here, and using your fix in branch master+libuvc-upstream it worked again.
Thanks.
Just wondering any chance this will be merged into master? It's already June 2021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants