OpenCV - Gstreamer pipeline

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

OpenCV - Gstreamer pipeline

ソリューションへジャンプ
9,646件の閲覧回数
fabianmpa019
Contributor II

Hi all,

I am trying to open a pipeline and create a VideoWriter object with OpenCV:

VideoCapture cap(" v4l2src ! video/x-raw,framerate=30/1,width=1920,height=1080 ! vpuenc_h264 ! avimux ! appsink ",CAP_GSTREAMER);
if(!cap.isOpened()){
std::cout<<"VideoCapture not opened";
exit(-1);
}
VideoWriter writer(" appsrc ! filesink location=video.avi ",0,30,Size(1920,1080),true);

 

It compiles, but when executed on the board i get:

Screenshot from 2020-09-02 02-26-07.png

Seems to be creating the pipeline but it gets stuck there.

Do you have any idea what could be happening?

Regards

0 件の賞賛
1 解決策
9,194件の閲覧回数
fabianmpa019
Contributor II

Still not working this way, however, cross compiling OpeCV with Gstreamer and FFmpeg support, i am able to run scripts I had no been able to run on Navq and it seems is using Gstreamer caps. The instructions on how I achieved it are under my gitbook  https://hovergames.gitbook.io/hovergames2/

元の投稿で解決策を見る

4 返答(返信)
9,195件の閲覧回数
fabianmpa019
Contributor II

Still not working this way, however, cross compiling OpeCV with Gstreamer and FFmpeg support, i am able to run scripts I had no been able to run on Navq and it seems is using Gstreamer caps. The instructions on how I achieved it are under my gitbook  https://hovergames.gitbook.io/hovergames2/

9,613件の閲覧回数
Landon_Haugh
NXP Employee
NXP Employee

Hey Fabian,

 

It seems as if you just created a VideoWriter object, but you aren't writing to that object. Is the source code you supplied the entirety of what you've compiled?

You need to add the following to your code in a loop:

 

Mat frame;
cap.read(frame);
writer.write(frame);

 

9,611件の閲覧回数
fabianmpa019
Contributor II

Hi!!

Right, the code i shared was not complete.

The complete code is:

#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;

int main()
{
      VideoCapture cap("v4l2src ! video/x-raw,framerate=30/1,width=1920,height=1080 ! vpuenc_h264 ! avimux ! appsink",CAP_GSTREAMER);
      if(!cap.isOpened()){
             cout<<"VideoCapture not opened";
             return -1;
       }
      VideoWriter writer("appsrc ! filesink location=video.avi",VideoWriter::fourcc('M','J','P','G'),15,Size(1920,1080),true);

      if(!writer.isOpened()){
             cout<<"VideoWriter not opened";
             return -1;
       }
       while(1){
              Mat frame;
              cap.read(frame);
              writer.write(frame);
              if(waitKey(1) == 27){
                     break;
               }
        }
        cap.release();
        writer.release();
        return 0;
}

 

0 件の賞賛
9,629件の閲覧回数
iaingalloway
NXP Employee
NXP Employee

We'll check on this.