leswright1977 / PySpectrometer2

The Second Incarnation of the Spectrometer project!
Apache License 2.0
204 stars 24 forks source link

Debian-Box USB Camera Error "unsupported operand type(s) for -: 'list' and 'int'" #4

Closed janoschsimon closed 1 year ago

janoschsimon commented 1 year ago

hey Les first of i love your project :) and as the Rpi prices are at the moment through the roof i didnt buy a rpi 4 instead i use my debian box with a fresh debin 11.5 i installed all depencies and tried if import cv2 work and it does...also the usb camera is founded via lsusb when i start PySpectrometer2-USB-v1.0.py a small blank window pops up for 1 sec and after that this message:

Loading calibration data...
Loading of Calibration data failed (missing caldata.txt or corrupted data!
Loading placeholder data...
You MUST perform a Calibration to use this software!

Calculating second order polynomial...
           2
3.125e-05 x + 0.4375 x + 380
Generating Wavelength Data!

Done! Note that calibration with only 3 wavelengths will not be accurate!
/home/xxxxxxxx/Documents/./PySpectrometer2-USB-v1.0.py:192: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
  np_data = np.fromstring(decoded_data,np.uint8)
Traceback (most recent call last):
  File "/home/xxxxxxxx/Documents/./PySpectrometer2-USB-v1.0.py", line 263, in <module>
    intensity = savitzky_golay(intensity,17,savpoly)
  File "/home/xxxxxxxx/Documents/specFunctions.py", line 143, in savitzky_golay
    lastvals = y[-1] + np.abs(y[-half_window-1:-1][::-1] - y[-1])
TypeError: unsupported operand type(s) for -: 'list' and 'int'

any idea whats wrong? thx janosch

leswright1977 commented 1 year ago

Yep, fromstring is deprecated (my dev box is quite old!) I have fixed the offending line. Please re-clone the repo, check if it errors and report back.

Cheers!

janoschsimon commented 1 year ago

the for the super fast replay :)

now i get

 janoschsimon@janosch-debian-box:~/Documents$ v4l2-ctl --list-devices
1.3M WebCam: 1.3M WebCam (usb-0000:00:1a.0-1.1):
    /dev/video0
    /dev/video1
    /dev/media0

janoschsimon@janosch-debian-box:~/Documents$ ./PySpectrometer2-USB-v1.0.py --device 0 --fps 15
[info] W, H, FPS
640.0
480.0
15.0
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
Loading calibration data...
Loading of Calibration data failed (missing caldata.txt or corrupted data!
Loading placeholder data...
You MUST perform a Calibration to use this software!

Calculating second order polynomial...
           2
3.125e-05 x + 0.4375 x + 380
Generating Wavelength Data!

Done! Note that calibration with only 3 wavelengths will not be accurate!
Traceback (most recent call last):
  File "/home/janoschsimon/Documents/./PySpectrometer2-USB-v1.0.py", line 263, in <module>
    intensity = savitzky_golay(intensity,17,savpoly)
  File "/home/janoschsimon/Documents/specFunctions.py", line 143, in savitzky_golay
    lastvals = y[-1] + np.abs(y[-half_window-1:-1][::-1] - y[-1])
TypeError: unsupported operand type(s) for -: 'list' and 'int'

and it seems that at the moment only the interal 1.3mpix is recognized hmmmmm

cheers and thx janosch

leswright1977 commented 1 year ago

Weird, I cant replicate this behaviour on the Pi or my Box, this may be a numpy version issue. On the Pi it is: 1.19.5 Check how to do this here:

https://arrayjson.com/numpy-version/

janoschsimon commented 1 year ago

meh i also have numpy 1.19.5 :/ any other idea? perhabs i should just get me raspbery pi 4 , ;)

leswright1977 commented 1 year ago

Ah! I see it!

In your output above it says: janoschsimon@janosch-debian-box:~/Documents$ ./PySpectrometer2-USB-v1.0.py --device 0 --fps 15 [info] W, H, FPS 640.0 480.0 15.0

The software expects 800px wide images to be pulled from the camera!

janoschsimon commented 1 year ago

ohhhh nooo i see thats the internal webcam very old hmmm and my machine vision cameras are also old on from daheng and one from point grey :/ will check tmr a new webcam and report back :) thx mate

leswright1977 commented 1 year ago

You are welcome. OpenCV is generally ok with the majority of webcams, but it is broken for some, so your milage may vary so to speak.

janoschsimon commented 1 year ago

Im back lee and got some great news and some more questions :) with the Logitech C920 PRO HD it works perfectly without anything i need to setup extra :) and the Industrycams i have a little success for my Point Grey Flea 3 USB3 camera i manage to install the SDK and the sample software Flycapture2 detects the camera and shows the picture but with v4l2-ctl --list-devices it wont show up :(

Bus 002 Device 006: ID 1e10:3006 Point Grey Research, Inc. Flea3 FL3-U3-13S2C 
janoschsimon@janosch-debian-box:~$ v4l2-ctl --list-devices
1.3M WebCam: 1.3M WebCam (usb-0000:00:1a.0-1.1):
    /dev/video0
    /dev/video1
    /dev/media0

hmmmm any idea how i can link the Flycapture SDK to your software? :) but im happy to see your software for the first time working hehe :)

leswright1977 commented 1 year ago

Glad you got it working for a least one camera! No that I am aware of. If the camera won't enumerate as a video device, it will not run with this software. PRobably softare woudl have to be written to work with the SDK.