I recently got I a ricoh theta x for 360 degree video stream over usb. I tried to use the following python code.
import cv2
# Open the default camera
cam = cv2.VideoCapture("/dev/video2")
if not cam.isOpened():
raise IOError("Cannot open webcam")
print("a")
# Get the default frame width and height
frame_width = int(cam.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height = int(cam.get(cv2.CAP_PROP_FRAME_HEIGHT))
print(frame_width,frame_height)
# Define the codec and create VideoWriter object
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter('output.mp4', fourcc, 20.0, (frame_width, frame_height))
while True:
ret, frame = cam.read()
# Write the frame to the output file
out.write(frame)
# Display the captured frame
cv2.imshow('Camera', frame)
# Press 'q' to exit the loop
if cv2.waitKey(1) == ord('q'):
break
# Release the capture and writer objects
cam.release()
out.release()
cv2.destroyAllWindows()
However, I can’t receive stream in linux (worked in windows 11). I installed libuvc-theta, libusb and other required libraries mentioned in here. I updated the firmware and I get the following outputs.
ptpcam --info
Camera information
==================
Model: RICOH THETA X
manufacturer: Ricoh Company, Ltd.
serial number: '20102026'
device version: 2.61.0
extension ID: 0x00000006
extension description: (null)
extension version: 0x006e
lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 0408:5477 Quanta Computer, Inc. HP Wide Vision HD Camera
Bus 001 Device 019: ID 05ca:2717 Ricoh Co., Ltd RICOH THETA X
Bus 001 Device 002: ID 046d:c246 Logitech, Inc. Gaming Mouse G300
Bus 001 Device 004: ID 8087:0033 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
v4l2-ctl --list-devices
RICOH THETA X: RICOH THETA X (usb-0000:00:14.0-3):
/dev/media1
HP Wide Vision HD Camera: HP Wi (usb-0000:00:14.0-6):
/dev/video0
/dev/video1
/dev/media0
Seems like it is recognized as a media device even though I set the live stream mode. Also, another interesting problem is that if I not set theta to usb stream mode from its screen, any of the usb commands mentioned in the documentation does not work since my computer cannot connect to theta.
Hi craig, sorry for late response. I was busy for the last 2 days. I am using ubuntu 22.04 and v4l2loopback is not supported if I am not wrong. I tried using gstthetauvc and got the following error.
sudo GST_DEBUG=3 gst-launch-1.0 thetauvcsrc mode=4K ! queue ! h264parse ! decodebin ! queue ! autovideosink sync=false
Setting pipeline to PAUSED …
0:00:00.226213399 10215 0x567491fa8130 WARN thetauvcsrc gstthetauvcsrc.c:512:gst_thetauvcsrc_start: error: Found 1 Theta(s), but none available.
ERROR: from element /GstPipeline:pipeline0/GstThetauvcsrc:thetauvcsrc0: Found 1 Theta(s), but none available.
Additional debug info:
gstthetauvcsrc.c(512): gst_thetauvcsrc_start (): /GstPipeline:pipeline0/GstThetauvcsrc:thetauvcsrc0
ERROR: pipeline doesn’t want to preroll.
0:00:00.226578742 10215 0x567491fa8130 WARN basesrc gstbasesrc.c:3556:gst_base_src_start: error: Failed to start
ERROR: from element /GstPipeline:pipeline0/GstThetauvcsrc:thetauvcsrc0: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
Additional debug info:
…/libs/gst/base/gstbasesrc.c(3556): gst_base_src_start (): /GstPipeline:pipeline0/GstThetauvcsrc:thetauvcsrc0:
Failed to start
ERROR: pipeline doesn’t want to preroll.
0:00:00.226720590 10215 0x567491fa8130 WARN basesrc gstbasesrc.c:3912:gst_base_src_activate_push: Failed to start in push mode
0:00:00.226735631 10215 0x567491fa8130 WARN GST_PADS gstpad.c:1141:gst_pad_set_active:thetauvcsrc0:src Failed to activate pad
Failed to set pipeline to PAUSED.
Setting pipeline to NULL …
Freeing pipeline …
I reinstalled thetauvc and run the previous command. I got the following output.
sudo GST_DEBUG=3 gst-launch-1.0 thetauvcsrc mode=4K ! queue ! h264parse ! decodebin ! queue ! autovideosink sync=false
Setting pipeline to PAUSED …
Pipeline is PREROLLING …
0:00:01.213323915 17353 0x63fc98a1e4c0 FIXME default gstutils.c:4025:gst_pad_create_stream_id_internal:thetauvcsrc0:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
Redistribute latency…
0:00:01.238461507 17353 0x63fc98a1e460 ERROR libav :0:: No start code is found.
0:00:01.238471321 17353 0x63fc98a1e460 ERROR libav :0:: Error splitting the input into NAL units.
0:00:01.238477323 17353 0x63fc98a1e460 WARN libav gstavviddec.c:2065:gst_ffmpegviddec_handle_frame:<avdec_h264-0> Failed to send data for decoding
0:00:01.292523638 17353 0x63fc98a1e460 ERROR libav :0:: No start code is found.
0:00:01.292556392 17353 0x63fc98a1e460 ERROR libav :0:: Error splitting the input into NAL units.
I guess thetauvc was not installed properly but now I have new problems . I build v4l2loopback from source successfully and run sudo modprobe v4l2loopback.
v4l2-ctl --list-devices
Dummy video device (0x0000) (platform:v4l2loopback-000):
/dev/video2
RICOH THETA X: RICOH THETA X (usb-0000:00:14.0-2):
/dev/media1
HP Wide Vision HD Camera: HP Wi (usb-0000:00:14.0-6):
/dev/video0
/dev/video1
/dev/media0
But still cv2.VideoCapture( “v4l2sink device=/dev/video1 qos=false sync=false”) fails.
I only have one additional camera (laptop’s webcam). Other than that, I only have theta. I unmounted as you explain, but still it is mounted as media .
Unfortunately, I do not know the solution as your system is different from mine.
It is puzzling why your cameras are being mounted as /dev/media
You can try removing the gvfs-gphoto2-volume-monitor and see if that is mounting the camera.
sudo apt remove gvfs-backends
Alternately, the article below shows how to kill the process as a test.
If it were me, I would try go into the HP bios and see if you can disable that HP Wide Vision camera as that thing is taking up two devices (don’t understand why it’s taking up two devices).
Setting live stream mode from usb works perfectly.
theta --set-property=0x5013 --val=0x8005
Camera: RICOH THETA X
‘Still Capture Mode’ is set to: 0x8005 (-32763)
Changing property value to 0x8005 [(null)] succeeded.
But still it is recognized as media device. sudo dmesg gives the following output.
[ 6085.851658] usb 1-2: Product: RICOH THETA X
[ 6085.851661] usb 1-2: Manufacturer: Ricoh Company, Ltd.
[ 6085.851664] usb 1-2: SerialNumber: YR20100599
[ 6085.863243] usb 1-2: Found UVC 1.50 device RICOH THETA X (05ca:2717)
[ 6085.864988] usb 1-2: No streaming interface found for terminal 3.