- Edited
Hello
My problem is the following:
I'm using the oak-d pro w to record camera data segmentwise. what i need are 5 minute video segments for e time period of about 10 hours, To do so i wrote this code:
def record_segment(self) -> str:
with OakCamera() as camera:
camera.device
color = camera.create_camera(
"color", resolution="1080P", fps=20, encode="H265"
)
stereo = camera.create_stereo(resolution="800p", fps=20, encode="H264")
stereo.config_wls(wls_level="medium")
outputs = [color.out.encoded, stereo.out.disparity]
record = camera.record(
outputs,
str(get_output_path() / self.subfolder),
record_type=RecordType.VIDEO,
)
# create pipline for camera sensors and imu sensor
imu = camera.pipeline.create(dai.node.IMU)
xlinkOut = camera.pipeline.create(dai.node.XLinkOut)
xlinkOut.setStreamName("imu")
imu.enableIMUSensor(
[dai.IMUSensor.ACCELEROMETER_RAW, dai.IMUSensor.GYROSCOPE_RAW], 100
)
imu.setBatchReportThreshold(1)
imu.setMaxBatchReports(10)
imu.out.link(xlinkOut.input)
camera.start()
imu_out = camera.device.getOutputQueue(
name="imu", maxSize=50, blocking=False
)
start_time = time.monotonic()
# running until out of time
with open("imu.csv", "a", newline="") as file:
writer = csv.writer(file)
while camera.running():
# get imu data during the camera is running
self.write_imu_data(imu_out.get().packets, writer)
if not self.record_condition(time.monotonic() - start_time):
camera.device.close()
camera.poll()
This function is called in a loop and records one segment. This all seems to work for some time but unfortunatly it breaks after one or two hours.
The error i get is X_LINK_DEVICE_NOT_FOUND. Even if i try to look up usb devices in linux (lsusb) i cant find the device. But if i reconnect it (plug in / plug out), it is found again.
In journalctl i see the following:
Jul 17 15:27:31 sensorbox python[844]: [2024-07-17 15:27:31] INFO [root.__exit__:408] Closing OAK camera
Jul 17 15:27:31 sensorbox python[844]: [2024-07-17 15:27:31] INFO [root.close:103] Video Recorder saved stream(s) to folder: /home/admin/media/usb/camera/41-194430105126A12E00
Jul 17 15:27:31 sensorbox python[844]: encoded 0 frames
Jul 17 15:27:31 sensorbox python[844]: 2024-07-17 15:27:31,619 - recorder.py:49 - INFO - Stop writing data segment
Jul 17 15:27:31 sensorbox python[844]: 2024-07-17 15:27:31,619 - recorder.py:41 - INFO - Start writing data segment
Jul 17 15:27:33 sensorbox python[844]: [2024-07-17 15:27:33] INFO [root._run:34] Exiting store frame thread
Jul 17 15:27:33 sensorbox kernel: usb 1-1: USB disconnect, device number 44
Jul 17 15:27:42 sensorbox kernel: usb 1-1: new high-speed USB device number 45 using xhci-hcd
Jul 17 15:27:42 sensorbox kernel: usb 1-1: New USB device found, idVendor=03e7, idProduct=2485, bcdDevice= 0.01
Jul 17 15:27:42 sensorbox kernel: usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jul 17 15:27:42 sensorbox kernel: usb 1-1: Product: Movidius MyriadX
Jul 17 15:27:42 sensorbox kernel: usb 1-1: Manufacturer: Movidius Ltd.
Jul 17 15:27:42 sensorbox kernel: usb 1-1: SerialNumber: 03e72485
Jul 17 15:27:42 sensorbox mtp-probe[4556]: checking bus 1, device 45: "/sys/devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-1"
Jul 17 15:27:42 sensorbox mtp-probe[4556]: bus: 1, device: 45 was not an MTP device
Jul 17 15:27:42 sensorbox mtp-probe[4557]: checking bus 1, device 45: "/sys/devices/platform/axi/1000120000.pcie/1f00200000.usb/xhci-hcd.0/usb1/1-1"
Jul 17 15:27:42 sensorbox mtp-probe[4557]: bus: 1, device: 45 was not an MTP device
Jul 17 15:27:48 sensorbox python[844]: 2024-07-17 15:27:48,084 - recorder.py:51 - ERROR - An error occured while recording
Jul 17 15:27:48 sensorbox python[844]: Traceback (most recent call last):
Jul 17 15:27:48 sensorbox python[844]: File "/home/admin/src/app/recorder.py", line 43, in record
Jul 17 15:27:48 sensorbox python[844]: name = self.record_segment()
Jul 17 15:27:48 sensorbox python[844]: File "/home/admin/src/app/camera/camera_recorder.py", line 28, in record_segment
Jul 17 15:27:48 sensorbox python[844]: with OakCamera() as camera:
Jul 17 15:27:48 sensorbox python[844]: File "/home/admin/environment/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 95, in __init__
Jul 17 15:27:48 sensorbox python[844]: self._init_device(config, device)
Jul 17 15:27:48 sensorbox python[844]: File "/home/admin/environment/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 378, in _init_device
Jul 17 15:27:48 sensorbox python[844]: self._oak.device = dai.Device(
Jul 17 15:27:48 sensorbox python[844]: RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND
Does anyone know what could be the problem that the device is not recognized after somne time? Thank you in advance!