<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: OpenCV and GStreamer on iMX8QM MEK in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/OpenCV-and-GStreamer-on-iMX8QM-MEK/m-p/1182296#M164843</link>
    <description>&lt;P&gt;I was able to make it work..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;const std::string pipeline = "filesrc location=/home/videos/RH-yuv420-slow.mp4 ! video/quicktime ! aiurdemux ! queue ! h264parse ! v4l2h264dec ! imxvideoconvert_g2d ! capsfilter caps=\"video/x-raw,format=UYVY,width=1392,height=512\" ! videoconvert ! queue ! appsink";

cv::VideoCapture cap(pipeline, cv::CAP_GSTREAMER);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;The key part is:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;STRONG&gt;! capsfilter caps=\"video/x-raw,format=UYVY,width=1392,height=512\" ! videoconvert &lt;/STRONG&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;were you are specifying the capture format.&lt;BR /&gt;&lt;BR /&gt;On the other had, for USB camera capture... you need to specify the&amp;nbsp; device ID (you can check the device ID using&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;v4l2-ctl --list-devices&lt;/EM&gt;&lt;/STRONG&gt; ) and the preferred Capture API backends to use; in this case cv::CAP_GSTREAMER.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;const int camID = 3;
cv::VideoCapture CAMcap(camID, cv::CAP_GSTREAMER);&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Nov 2020 11:47:29 GMT</pubDate>
    <dc:creator>sebadavalle</dc:creator>
    <dc:date>2020-11-12T11:47:29Z</dc:date>
    <item>
      <title>OpenCV and GStreamer on iMX8QM MEK</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/OpenCV-and-GStreamer-on-iMX8QM-MEK/m-p/1179587#M164610</link>
      <description>&lt;P&gt;Hi I need help capturing MP4 videos using openCV and GSTREAMER.&lt;STRONG&gt;&lt;U&gt;&lt;BR /&gt;&lt;BR /&gt;Environment:&lt;/U&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Board:&lt;/STRONG&gt; i.MX8 Quad Max MEK&lt;BR /&gt;&lt;STRONG&gt;Linux:&lt;/STRONG&gt; NXP i.MX Release Distro 5.4-zeus imx8qmmek&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;This is the way I'm playing back MP4 the videos:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;gst-launch-1.0 filesrc location=/home/LH.mp4 ! video/quicktime ! aiurdemux ! queue ! h264parse ! v4l2h264dec ! imxvideoconvert_g2d ! queue ! waylandsink &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So based on that I built the following pipeline for VideoCapture function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;cv::VideoCapture LHcap("filesrc location=/home/LH.mp4 ! video/quicktime ! aiurdemux ! queue ! h264parse ! v4l2h264dec ! imxvideoconvert_g2d ! queue ! appsink", cv::CAP_GSTREAMER)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;But&lt;/STRONG&gt;, the frames captured has only 2 channel and all OpenCV conversion functions fails.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;cv::Mat img;
LHcap &amp;gt;&amp;gt; img;
cout &amp;lt;&amp;lt;  img.channels() &amp;lt;&amp;lt; endl;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So i tried another&amp;nbsp;pipeline&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;filesrc location=/home/LH.mp4 ! decodebin ! videorate ! video/x-raw,framerate=1/1 ! videoconvert ! video/x-raw, format=(string)BGR ! appsink&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;using this pipeline, the captured images have 3 channels and the type is well recognized (CV_8UC3), &lt;STRONG&gt;BUT,&lt;/STRONG&gt;&amp;nbsp;if I save one of the frames, I can see the image is broken&lt;BR /&gt;&lt;BR /&gt;(See attached)&lt;BR /&gt;&lt;BR /&gt;Does anybody knows how to capture mp4 videos using opencv and GSREAMER?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Seba.-&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 19:18:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/OpenCV-and-GStreamer-on-iMX8QM-MEK/m-p/1179587#M164610</guid>
      <dc:creator>sebadavalle</dc:creator>
      <dc:date>2020-11-06T19:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: OpenCV and GStreamer on iMX8QM MEK</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/OpenCV-and-GStreamer-on-iMX8QM-MEK/m-p/1182296#M164843</link>
      <description>&lt;P&gt;I was able to make it work..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;const std::string pipeline = "filesrc location=/home/videos/RH-yuv420-slow.mp4 ! video/quicktime ! aiurdemux ! queue ! h264parse ! v4l2h264dec ! imxvideoconvert_g2d ! capsfilter caps=\"video/x-raw,format=UYVY,width=1392,height=512\" ! videoconvert ! queue ! appsink";

cv::VideoCapture cap(pipeline, cv::CAP_GSTREAMER);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;The key part is:&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;EM&gt;&lt;STRONG&gt;! capsfilter caps=\"video/x-raw,format=UYVY,width=1392,height=512\" ! videoconvert &lt;/STRONG&gt;&lt;/EM&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;were you are specifying the capture format.&lt;BR /&gt;&lt;BR /&gt;On the other had, for USB camera capture... you need to specify the&amp;nbsp; device ID (you can check the device ID using&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;v4l2-ctl --list-devices&lt;/EM&gt;&lt;/STRONG&gt; ) and the preferred Capture API backends to use; in this case cv::CAP_GSTREAMER.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;const int camID = 3;
cv::VideoCapture CAMcap(camID, cv::CAP_GSTREAMER);&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2020 11:47:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/OpenCV-and-GStreamer-on-iMX8QM-MEK/m-p/1182296#M164843</guid>
      <dc:creator>sebadavalle</dc:creator>
      <dc:date>2020-11-12T11:47:29Z</dc:date>
    </item>
  </channel>
</rss>

