wzyy2 / gstreamer-opencv

opencv + gstreamer simple demo
132 stars 42 forks source link

Run gst_opencv fail in TinkerBoard with TinkerOS #2

Open topdjgod opened 6 years ago

topdjgod commented 6 years ago

Hi, Sample code doesn't work in TinkerBoard. Build OK, but run with Segmentation fault - Unable to set the pipeline to the playing stateEnter to leave! Is there anything missing?

wzyy2 commented 6 years ago

Do you use TinkerOS? You might need update video packages from https://github.com/rockchip-linux/rk-rootfs-build/tree/master/packages/armhf/video, because i have fix some bugs in gstreamer-rockchip/mpp/gstreamer-rockchip-extra when writing this program......

wzyy2 commented 6 years ago

And make sure your kernel have RGA enabled.

topdjgod commented 6 years ago

Thanks for your advice. Video test is working now. But usb camera test has a problem as below:

ard:~/gstreamer-opencv$ ./gst_opencv GStreamer V1.10.4.0 mpi: mpp version: b212d1b author: Jacob Chen [mpp]: fix mjpeg buffer leak mpi: mpp version: b212d1b author: Jacob Chen [mpp]: fix mjpeg buffer leak Enter to leave! mpp_buf_slot: new width 1280 height 720 stride hor 1280 ver 720 fmt 2 (--gst-version:914): GLib-GObject-WARNING : cannot register existing type 'GstV4l2BufferPool' (--gst-version:914): GLib-CRITICAL : g_once_init_leave: assertion 'result != 0' failed (--gst-version:914): GLib-GObject-CRITICAL : g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed (--gst-version:914): GLib-GObject-CRITICAL : g_object_ref_sink: assertion 'G_IS_OBJECT (object)' failed

wzyy2 commented 6 years ago

There are so problems in dwc2 usb port.. Could you try a lower resultion?

topdjgod commented 6 years ago

After changing rgaconvert to v4l2video0convert, usb camera is working. Seems that rgaconvert has a problem with usb camera?!!

wzyy2 commented 6 years ago

Did you use output-io-mode=dmabuf-import?

topdjgod commented 6 years ago

Use "v4l2video0convert output-io-mode=dmabuf capture-io-mode=dmabuf " that can work. Use "rgaconvert output-io-mode=dmabuf-import capture-io-mode=dmabuf" doesn't work.

wzyy2 commented 6 years ago

It's due todmabuf-import.. I'm not sure why it failed. Using output-io-mode=dmabuf have a bad impact on performance.

scorpiochang commented 6 years ago

Hi wzyy2

I am user of Tinker Board. Hello... I get some problem, and more detail as below:

  1. I pull newest kernel source of RK and merge it to my codebase.
  2. set CONFIG_VIDEO_ROCKCHIP_RGA=y, kernel/drivers/media/platform/rockchip-rga/rga.c will gen /dev/video0
  3. make sure IMX219 can preview by gst-launch-1.0 v4l2src device=/dev/video1 ! video/x-raw,format=NV12,width=640,height=480,framerate=30/1" ! videoconvert ! autovideosink
  4. git clone gstreamer-opencv
  5. update gstreamer1.0-rockchip1-extra_1.10-1_armhf.deb
  6. because i use CSI camera, so i modify PipeLines.h as below:

static std::string CreateAppSinkPipeline() { std::stringstream pipelineString;

pipelineString
    << "v4l2src device=/dev/video1"
    << LINK
    << "video/x-raw,format=(string)NV12,width=(int)1280,height=(int)720,framerate=(fraction)30/1"

// << "mppvideodec" // << LINK // << "video/x-raw,formar=(string)NV12" << LINK << "v4l2video0convert output-io-mode=dmabuf capture-io-mode=dmabuf" << LINK << "video/x-raw,format=(string)BGR,width=(int)1280,height=(int)720,framerate=(fraction)30/1" << LINK << "appsink name=" << APPSINK_NAME;

return pipelineString.str();

}

it's work, but as you said "Using output-io-mode=dmabuf have a bad impact on performance."

so, i change "v4l2video0convert output-io-mode=dmabuf capture-io-mode=dmabuf" to "rgaconvert output-io-mode=dmabuf-import capture-io-mode=dmabuf"

but i get the error message as below

0:00:00.430201724 1558 0x80850660 ERROR v4l2 gstv4l2object.c:1897:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

0:00:00.430291849 1558 0x80850660 ERROR v4l2 gstv4l2object.c:1897:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

(--gst-version:1558): GLib-GObject-WARNING **: cannot register existing type 'GstV4l2BufferPool'

(--gst-version:1558): GLib-CRITICAL **: g_once_init_leave: assertion 'result != 0' failed

(--gst-version:1558): GLib-GObject-CRITICAL **: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

(--gst-version:1558): GLib-GObject-CRITICAL **: g_object_ref_sink: assertion 'G_IS_OBJECT (object)' failed

is my config of PipeLines.h wrong? thank you.

wzyy2 commented 6 years ago

It's fixed now, please update gstreamer-rockchip-extra. https://github.com/rockchip-linux/gstreamer-rockchip-extra/commit/11648d7e2a222c2ece0dd0e79e696606d03989ec

scorpiochang commented 6 years ago

Hi wzyy2

after i update newest gstreamer1.0-rockchip1-extra_1.10-1_armhf.deb

I get newer message as below: 0:00:00.454539258 1250 0x80e77860 ERROR v4l2 gstv4l2object.c:1897:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

requesting 4 MMAP buffersEnter to leave! 0:00:00.581030501 1250 0x80e77860 ERROR rk_v4l2allocator v4l2/gstv4l2allocator.c:1128:gst_v4l2_allocator_import_dmabuf: Memory 0 is not of DMABUF 0:00:00.581125585 1250 0x80e77860 ERROR rk_v4l2bufferpool v4l2/gstv4l2bufferpool.c:369:gst_v4l2_buffer_pool_import_dmabuf: failed to import dmabuf 0:00:00.581169919 1250 0x80e77860 ERROR rk_v4l2bufferpool v4l2/gstv4l2bufferpool.c:1984:gst_v4l2_buffer_pool_process: failed to prepare data

kernel also had some message as below:

[ 137.300654] cif_isp10_v4l2_requeue_bufs(1274) ERR: skip state change for buf: 1, state: 6 [ 137.309725] cif_isp10_v4l2_requeue_bufs(1274) ERR: skip state change for buf: 2, state: 6 [ 137.309730] cif_isp10_v4l2_requeue_bufs(1274) ERR: skip state change for buf: 3, state: 6 [ 137.309734] cif_isp10_v4l2_requeue_bufs(1274) ERR: skip state change for buf: 4, state: 6 [ 137.309745] cif_isp10_v4l2_requeue_bufs(1274) ERR: skip state change for buf: 5, state: 6

thank you. @@

wzyy2 commented 6 years ago

For mipi camera, you don't need to use mppvideodec, replace it with "video/x-raw,format=NV12,width=(int)1920,height=(int)1080"

scorpiochang commented 6 years ago

okay, i don't use mppvideodec as my previous comment.

and i modify "video/x-raw,format=(string)NV12,width=(int)1280,height=(int)720,framerate=(fraction)30/1" to "video/x-raw,format=(string)NV12,width=(int)1280,height=(int)720"

there are no error message but get black content of output window.

the kernel show message: [ 1339.939032] dwhdmi-rockchip ff980000.hdmi: event 2 [ 1339.945154] dwhdmi-rockchip ff980000.hdmi: event 3 [ 1340.058097] dwhdmi-rockchip ff980000.hdmi: event 2 [ 1340.064371] dwhdmi-rockchip ff980000.hdmi: event 3 [ 1340.178367] dwhdmi-rockchip ff980000.hdmi: event 2 [ 1340.184915] dwhdmi-rockchip ff980000.hdmi: event 3

can you help on it again!

scorpiochang commented 6 years ago

Hi wzyy2

for more information, USB camera is work fine (use rgaconvert), no more modification in PipeLine.h thank you.

PatelKishanJ commented 5 years ago

Hello, I have seen "gstreamer-opencv" link which can be useful for rockchip with hardware codecs.

Can you describe me which other dependencies i have to use? Means "OpenCV version", which i have to install? Which OS, i have to use(ubuntu/armbian)?

I have Rockpro64 Board.

Thanks in advance, Regards, Kishan Patel.