Linux-tiscamera-Programming-Samples icon indicating copy to clipboard operation
Linux-tiscamera-Programming-Samples copied to clipboard

Problem with running CPP samples

Open mhcybo opened this issue 2 years ago • 6 comments

I am trying cpp samples of Linux-tiscamera-Programming-Samples repository and and have different types of errors. Specifically for /cpp/Save an image using OpenCV/ project, after making and running I get these errors:

ERROR tcam-libtcam V4l2Device.cpp:306:release_buffers: Error while calling VIDIOC_REQBUFS to empty buffer queue. Device or resource busy ERROR tcam-libtcam V4l2Device.cpp:114:set_video_format: Error while calling VIDIOC_REQBUFS to empty buffer queue. Device or resource busy ERROR tcam-libtcam V4l2Device.cpp:146:set_video_format: Error while setting format 'Device or resource busy' ERROR tcammainsrc gsttcammainsrc.cpp:351:gst_tcam_mainsrc_set_caps: Unable to set format in device

I am using a DFK 33UX183 camera and with a Nvidia Jetson (with Ubuntu and Jetpack) system. I can access to camera frames using gst-launch-1.0 tcamsrc... command in the terminal, but in those cpp codes it's not working.

Thank you

mhcybo avatar Jul 26 '23 01:07 mhcybo

Hello It seems you have frame drops. Please try a lower frame rate and see, what happens. Maybe the camera is also used by another process. Do you get images with tcam-capture? Did you dis- and reconnect the camera?

Stefan

TIS-Stefan avatar Jul 26 '23 07:07 TIS-Stefan

Hi Thank you for the reply. Yes actually I tried all those acts including different resolutions/fps. Although I cannot get the image using tcam-capture since I don't have any display (I am using remote connection)

$ tcam-capture -h
2023-07-27T11:48:43 - unknown:0: warning QXcbConnection: Could not connect to display
2023-07-27T11:48:43 - unknown:0: critical Could not connect to any X display.

As another example, using this sample and this command in the code:

std::string p = "tcambin name=source ! video/x-raw,format=BGR,width=640,height=480,framerate=1/1 ! appsink sync=false name=sink";

I get the following error:

$ ./tcamopencvsaveimage 
tcambin name=source ! video/x-raw,format=BGR,width=640,height=480,framerate=1/1 ! appsink sync=false name=sink
ASYNC WaitForChangeState() change to state 4 failed

mhcybo avatar Jul 27 '23 02:07 mhcybo

@TIS-Stefan Is there any idea on this issue?

mhcybo avatar Aug 14 '23 00:08 mhcybo

Hello I must admit, I have totally no idea, what is wrong on your hardware. I would change to a Linux desktop computer and see, how the camera behaves there, just to exclude a camera issue.

I thought, I answered your request 3 weeks ago. A pipeline for SSH access would be

gst-launch-1.0 tcambin ! video/x-raw,format=BGR,width=640,height=480,framerate=30/1 ! videoconvert ! aaysink sync=false

A frame rate of 1/1 wont work, because it is not in the USB descriptor of the camera. Available frame rates for v4l2 can be listed by

tcam-ctrl -c

Stefan

TIS-Stefan avatar Aug 14 '23 06:08 TIS-Stefan

@TIS-Stefan

Thank you for the follow up.

In the command line I am able to get a correct video with this command:

gst-launch-1.0 tcamsrc serial=<...> num-buffers=40 do-timestamp=True ! 'video/x-bayer, format=rggb, width=5472, height=3648, framerate=18/1' ! tcamdutils-cuda ! videoconvert ! 'video/x-raw, width=5472, height=3648, format=(string)NV12' ! nvvidconv ! 'video/x-raw(memory:NVMM), format=(string)I420' ! nvv4l2h265enc ! h265parse ! qtmux ! filesink location="./1.mp4"

So I guess hardware is working fine. Is there a full documentation of the codes and commands that we can use for calling the camera? If I make a small change in the parameters of the command, I will get different types are error which necessary doesn't show the true problem (the logs are not helpful).

mhcybo avatar Aug 17 '23 07:08 mhcybo

@TIS-Stefan

With the command that you mentioned, I get this output:

gst-launch-1.0 tcambin ! video/x-raw,format=BGR,width=640,height=480,framerate=30/1 ! videoconvert ! appsink sync=false
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
INFO:
Working with src caps: video/x-raw, format=(string)BGR, width=(int)640, height=(int)480, framerate=(fraction)30/1
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstTcamBin:tcambin0/GstTcamSrc:tcambin-source/GstTcamMainSrc:tcammainsrc0: Internal data stream error.
Additional debug info:
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstTcamBin:tcambin0/GstTcamSrc:tcambin-source/GstTcamMainSrc:tcammainsrc0:
streaming stopped, reason not-negotiated (-4)
Execution ended after 0:00:02.326435645
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

mhcybo avatar Aug 17 '23 07:08 mhcybo