Open JimKnopfIoT opened 5 months ago
Haven't run Arch before. What version/variant of Arch are you running ?
Are you running through a USB hub or straight to the PC ?
Also, can you try running and posting the results of:
v4l2-ctl --list-devices --all
USB Camera: USB Camera (usb-0000:00:14.0-1):
/dev/video0
/dev/video1
/dev/media0
Driver Info:
Driver name : uvcvideo
Card type : USB Camera: USB Camera
Bus info : usb-0000:00:14.0-1
Driver version : 6.1.55
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : uvcvideo
Model : USB Camera: USB Camera
Serial : 200901010001
Bus info : usb-0000:00:14.0-1
Media version : 6.1.55
Hardware revision: 0x00001101 (4353)
Driver version : 6.1.55
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : USB Camera: USB Camera
Function : V4L2 I/O
Flags : default
Pad 0x01000007 : 0: Sink
Link 0x02000010: from remote pad 0x100000a of entity 'Extension 4': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Input 1: ok)
Format Video Capture:
Width/Height : 256/384
Pixel Format : 'YUYV' (YUYV 4:2:2)
Field : None
Bytes per Line : 512
Size Image : 196608
Colorspace : sRGB
Transfer Function : Rec. 709
YCbCr/HSV Encoding: ITU-R 601
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 256, Height 384
Default : Left 0, Top 0, Width 256, Height 384
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 256, Height 384, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 256, Height 384, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 25.000 (25/1)
Read buffers : 0
User Controls
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=100 step=1 default=50 value=50
saturation 0x00980902 (int) : min=0 max=100 step=1 default=64 value=64
hue 0x00980903 (int) : min=-180 max=180 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=100 max=500 step=1 default=300 value=300
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=10 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=100 step=1 default=50 value=50
backlight_compensation 0x0098091c (int) : min=0 max=1 step=1 default=0 value=0
Camera Controls
auto_exposure 0x009a0901 (menu) : min=0 max=3 default=3 value=3
1: Manual Mode
3: Aperture Priority Mode
exposure_time_absolute 0x009a0902 (int) : min=50 max=10000 step=1 default=166 value=166 flags=inactive
exposure_dynamic_framerate 0x009a0903 (bool) : default=0 value=1
@92es It was once a bbqlinux. But now i grab the default arch repo.
# uname -a
Linux ROG 6.8.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 11 Apr 2024 01:47:33 +0000 x86_64 GNU/Linux
# v4l2-ctl --list-devices --all
v4l2-ctl --list-devices --all
USB Camera: USB Camera (usb-0000:3d:00.0-1):
/dev/video12
/dev/video13
/dev/media12
Cannot open device /dev/video0, exiting.
v4l2-ctl --list-devices --all is having trouble dumping your thermal camera on Arch.
Does some other program have control of it ?
Cheese/mplayer recognice the device and show 2 images. And guvcview show me a gray images with thermal recognition.
After reconnecting, /dev/video0 changes to /dev/video1 and now i have colored picture in guvcview.
I tried the v4l2-ctl command again, pointing to the /dev/video device the P2Pro actually is connected to:
v4l2-ctl -d /dev/video9 --all
Driver Info:
Driver name : uvcvideo
Card type : USB Camera: USB Camera
Bus info : usb-0000:3d:00.0-1
Driver version : 6.8.7
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : uvcvideo
Model : USB Camera: USB Camera
Serial : 200901010001
Bus info : usb-0000:3d:00.0-1
Media version : 6.8.7
Hardware revision: 0x00001101 (4353)
Driver version : 6.8.7
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1) v4l2-ctl -d /dev/video9 --all
Driver Info:
Driver name : uvcvideo
Card type : USB Camera: USB Camera
Bus info : usb-0000:3d:00.0-1
Driver version : 6.8.7
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : uvcvideo
Model : USB Camera: USB Camera
Serial : 200901010001
Bus info : usb-0000:3d:00.0-1
Media version : 6.8.7
Hardware revision: 0x00001101 (4353)
Driver version : 6.8.7
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : USB Camera: USB Camera
Function : V4L2 I/O
Flags : default
Pad 0x01000007 : 0: Sink
Link 0x02000010: from remote pad 0x100000a of entity 'Extension 4' (Video Pixel Formatter): Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 256/192
Pixel Format : 'YUYV' (YUYV 4:2:2)
Field : None
Bytes per Line : 512
Size Image : 98304
Colorspace : sRGB
Transfer Function : Rec. 709
YCbCr/HSV Encoding: ITU-R 601
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 256, Height 192
Default : Left 0, Top 0, Width 256, Height 192
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 256, Height 192, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 256, Height 192, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 25.000 (25/1)
Read buffers : 0
User Controls
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=100 step=1 default=50 value=50
saturation 0x00980902 (int) : min=0 max=100 step=1 default=64 value=64
hue 0x00980903 (int) : min=-180 max=180 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=100 max=500 step=1 default=300 value=300
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1 (50 Hz)
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=10 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=100 step=1 default=50 value=50
backlight_compensation 0x0098091c (int) : min=0 max=1 step=1 default=0 value=0
Camera Controls
auto_exposure 0x009a0901 (menu) : min=0 max=3 default=3 value=3 (Aperture Priority Mode)
1: Manual Mode
3: Aperture Priority Mode
exposure_time_absolute 0x009a0902 (int) : min=50 max=10000 step=1 default=166 value=166 flags=inactive
exposure_dynamic_framerate 0x009a0903 (bool) : default=0 value=1
Name : USB Camera: USB Camera
Function : V4L2 I/O
Flags : default
Pad 0x01000007 : 0: Sink
Link 0x02000010: from remote pad 0x100000a of entity 'Extension 4' (Video Pixel Formatter): Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 256/192
Pixel Format : 'YUYV' (YUYV 4:2:2)
Field : None
Bytes per Line : 512
Size Image : 98304
Colorspace : sRGB
Transfer Function : Rec. 709
YCbCr/HSV Encoding: ITU-R 601
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 256, Height 192
Default : Left 0, Top 0, Width 256, Height 192
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 256, Height 192, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 256, Height 192, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 25.000 (25/1)
Read buffers : 0
User Controls
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=100 step=1 default=50 value=50
saturation 0x00980902 (int) : min=0 max=100 step=1 default=64 value=64
hue 0x00980903 (int) : min=-180 max=180 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=100 max=500 step=1 default=300 value=300
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1 (50 Hz)
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=10 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=100 step=1 default=50 value=50
backlight_compensation 0x0098091c (int) : min=0 max=1 step=1 default=0 value=0
Camera Controls
auto_exposure 0x009a0901 (menu) : min=0 max=3 default=3 value=3 (Aperture Priority Mode)
1: Manual Mode
3: Aperture Priority Mode
exposure_time_absolute 0x009a0902 (int) : min=50 max=10000 step=1 default=166 value=166 flags=inactive
exposure_dynamic_framerate 0x009a0903 (bool) : default=0 value=1
I can't reproduce the colored image in guvcview. But using this command i found on eevblog, i get also an colored video:
ffmpeg -input_format yuyv422 -video_size 256x384 -i /dev/video4 -vf 'crop=h=(ih/2):y=(ih/2)' -pix_fmt yuyv422 -f rawvideo - | ffplay -pixel_format gray16le -video_size 256x192 -f rawvideo -i - -vf 'normalize=smoothing=10, format=pix_fmts=rgb48, pseudocolor=p=inferno'
From the v4l2 data dump, the image dimensions and byte size appears to be off by half.
The app expects 256 x ( 192 x 2 ) x 2 bytes per pixel which is 196608 bytes.
Width/Height : 256/384
...
...
Bytes per Line : 512
Size Image : 196608
Your dump is showing half of what the app expects.
Width/Height : 256/192
...
...
Bytes per Line : 512
Size Image : 98304
Your keyboard images show both frames so I would guess it is trying to store the data in 1 byte per pixel vs 2 bytes per pixel.
To verify this assumption, I added TC00120240122-131607.png and TC00120240122-131607.raw file to the media directory.
If you download the .raw file and run it in offline mode, we can see if the rest of the app is working.
Offline Usage:
./redux -f input.raw (where input.raw is a raw dump file from ./redux)
If Arch is returning 1bpp, either that has to be changed or the app has to be changed, hopefully without data/precision loss.
TC00120240122-131607.png:
Here is the run on Debian 11:
./redux -f ../media/TC00120240122-131607.raw
Startup timings: s 0.088, var 0.359, suo 0.019, pa 0.002, pkb 0.211, nw 297.292, run 0.240, total 298.211
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.9.0) /usr/src/debug/opencv/opencv-4.9.0/modules/imgproc/src/color.simd_helpers.hpp:113: error: (-215:Assertion failed) sz.width % 2 == 0 in function 'CvtHelper'
Abgebrochen (Speicherabzug geschrieben)
Well, that didn't look promising. =(
I see you posted on LeoDJ's thread. Have you tried using Lester's basic python script(s) to see if OpenCV has issues there as well ?
He has a raw script which just dumps the video. His other script does some basic data mining.
The raw script might be the simplest debugging step. Then the data mining script. The OpenCV python APIs call into a C/C++ implementation from what I understand.
Raw python video script, no data mining.
#!/usr/bin/env python3
import cv2
import numpy as np
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--device", type=int, default=0, help="Video Device number e.g. 0, use v4l2-ctl --list-devices")
args = parser.parse_args()
if args.device:
dev = args.device
else:
dev = 0
#init video
cap = cv2.VideoCapture('/dev/video'+str(dev), cv2.CAP_V4L)
#cap.set(cv2.CAP_PROP_CONVERT_RGB,False)
cap.set(cv2.CAP_PROP_CONVERT_RGB,0.0)
#we need to set the resolution here why?
'''
wright@CF-31:~/Desktop$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Size: Discrete 256x192
Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 256x384
Interval: Discrete 0.040s (25.000 fps)
'''
scale = 3
width = (256 * scale)
height = (192 * scale)
name = 'Thermal'
cv2.namedWindow(name,cv2.WINDOW_GUI_NORMAL)
cv2.resizeWindow(name, width, height) # Scale window once to desired scale
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
if ret == True:
cv2.namedWindow(name,cv2.WINDOW_NORMAL)
imdata,thdata = np.array_split(frame, 2) # Split into individual sub-frames
imdata = cv2.cvtColor(imdata, cv2.COLOR_YUV2BGR_YUYV)
imdata = cv2.resize(imdata, (width, height), cv2.INTER_CUBIC)
imdata = cv2.applyColorMap(imdata, cv2.COLORMAP_JET)
cv2.imshow(name,imdata)
keyPress = cv2.waitKey(3)
if keyPress == ord('q'):
break
capture.release()
cv2.destroyAllWindows()
Another alternative, do you have a Debian 11 or 12 install ? The app was written on Debian 11 and tested on the latest RPi OS's based off of Debian 12.
Running the script leads to this error:
python ./lester.py
Traceback (most recent call last):
File "/opt/Thermal-Camera-Redux/src/./lester.py", line 53, in <module>
imdata = cv2.cvtColor(imdata, cv2.COLOR_YUV2BGR_YUYV)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cv2.error: OpenCV(4.9.0) /io/opencv/modules/imgproc/src/color.simd_helpers.hpp:92: error: (-2:Unspecified error) in function 'cv::impl::{anonymous}::CvtHelper<VScn, VDcn, VDepth, sizePolicy>::CvtHelper(cv::InputArray, cv::OutputArray, int) [with VScn = cv::impl::{anonymous}::Set<2>; VDcn = cv::impl::{anonymous}::Set<3, 4>; VDepth = cv::impl::{anonymous}::Set<0>; cv::impl::{anonymous}::SizePolicy sizePolicy = cv::impl::<unnamed>::FROM_UYVY; cv::InputArray = const cv::_InputArray&; cv::OutputArray = const cv::_OutputArray&]'
> Invalid number of channels in input image:
> 'VScn::contains(scn)'
> where
> 'scn' is 1
I have a Chuwi LarkBox, running Ubuntu:
uname -a
Linux LarkBox 6.5.0-28-generic #29~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr 4 14:39:20 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Redux is working fine on this device.
I have some RPi 4 laying around. I'm sure it will work on it. But i want get it to work on my Arch Linux device.
Well, that is good to see it is running on Ubuntu ( not as a VM guest ).
If you try the RPi, try the latest OS based off of Debian 12, not Debian 10 or earlier.
As for Arch, you are blazing new territory.
Les's Python script threw an error indicating it has unexpected number of channels in the image.
The "v4l2-ctl -d /dev/video9 --all" output appears to concur indicating 1bpp versus 2bpp.
This may be indicative of Arch's implementation of OpenCV and/or their OpenCV backend. I have seen similar incompatibilities when vendors reinvent the world in their own image ( e.g. IBM absolutely butchered OpenGL in their flagship workstations ).
Debian is not based on other distribution.
<<< Arch Linux is a distribution independent of Debian or any other Linux distribution. >>>
Ubuntu is a popular Debian-based distribution commercially sponsored by Canonical Ltd.,
while Arch is an independently developed system built from scratch.
The two projects have very different goals and are targeted at a different user base.
``Hi there,
I did some tests on Archlinux too with an Infiray P2 Pro. Same error with ./redux -d 2
.
Startup timings: s 0.153, var 0.061, suo 0.024, pa 268.822, pkb 1.112, nw 490.647, run 0.439, total 761.258
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(4.9.0) /usr/src/debug/opencv/opencv/modules/imgproc/src/color.simd_helpers.hpp:113: error: (-215:Assertion failed) sz.width % 2 == 0 in function 'CvtHelper'
zsh: IOT instruction (core dumped) ./redux -d 2
But if I use the scale option I managed to get a pretty good image:
./redux -d 2 -scale 3
My tests with differents scales options:
I hope it could help finding the issue or just use it on arch as this.
Regards Pierre
Be sure to set your DISPLAY's resolution in your compile options (DEFAULT_FLAGS) BEFORE building. Building with them too small will cause issues.
-DDISPLAY_WIDTH=2560 -DDISPLAY_HEIGHT=1600
Also, 1X scale is too crowded for advanced features.
256x192 pixels is quite limited. I normally run @ 4X or 5X scale.
Glad to hear it is "working" on Arch.
@92es Thanks for your help.
Best build settings for me on my laptop:
DEFAULT_FLAGS='-DBORDER_LAYOUT=0 -DDEFAULT_FONT=0 -DDEFAULT_COLORMAP=4 -DROTATION=270 -DDISPLAY_WIDTH=2560 -DDISPLAY_HEIGHT=1440 -DUSE_CELSIUS=1 -DHUD_ALPHA=0.4'
And running options:
./redux -d 2 -scale 3
It strange that only odd numbers works to set scale on arch with opencv 4.9
Pierre
@equinoxefr
You may like -DBORDER_LAYOUT=1 to move some of the graphics off the video image.
Scaling and interpolation is done with library calls.
What version of Arch are you running ?
Thanks for your information. I have never ran Arch before.
Ok I will try this 👌
My distrib is a sister of arch, it's a Manjaro. Pretty similar, almost the same packages and versions.
Can't start redux on Arch Linux. Camera is an Infiray P2 Pro which is detected as Realtek USB Camera:
I have installed opencv:
There is no libopencv-dev for Arch. Must have included in opencv i guess. Compiled it without errors. But when running ./redux -d 5, there is a small black windows for half a second and i get this error: