【发布时间】:2018-05-26 15:33:49
【问题描述】:
我正在尝试从 opencv (c++) 中写入 gstreamer 管道。我已经设置好了,但是当我运行程序时没有输出,没有错误,甚至没有任何迹象表明它甚至在代码中。它只是没有做任何事情。我试过使用“-vvv”,所以它会显示它在做什么,但没有结果。这是我的代码:
#include "opencv2/opencv.hpp"
#include <string>
#include <iostream>
#include <sstream>
#include <stdio.h>
using namespace cv;
using namespace std;
using namespace cv;
int main(int, char**)
{
const char* right_cam_gst = "nvcamerasrc sensor-id=0 ! video/x-raw(memory:NVMM),\
width=(int)640,\
height=(int)360,\
format=(string)I420,\
framerate=(fraction)10/1 ! nvvidconv flip-method=2 ! video/x-raw,\
format=(string)I420 ! videoconvert ! video/x-raw,\
format=(string)BGR ! appsink";
VideoCapture capture(right_cam_gst); // open the default camera
if(!capture.isOpened()) // check if we succeeded
return -1;
VideoWriter writer;
writer.open("-vvv appsrc ! video/x-raw,format=YUY2,width=640,height=480 ! jpegenc ! rtpjpegpay ! udpsink -vvv host=127.0.0.1 port=5000", 0, (double)10, Size(640, 360), true);
Mat distCoeffs;
Mat intrinsic;
cv::FileStorage storage("CamData.yml", cv::FileStorage::READ);
storage["distCoeffs"] >> distCoeffs;
storage["intrinsic"] >> intrinsic;
storage.release();
Mat image;
Mat imageUndistorted;
while(1)
{
capture >> image;
undistort(image, imageUndistorted, intrinsic, distCoeffs);
writer << imageUndistorted;
// imshow("win1", image);
imshow("win2", imageUndistorted);
waitKey(1);
}
capture.release();
return 0;
}
很简单。它抓取视频,不失真,然后将其打印到 imwrite 和 gstreamer 管道(视频使用 imwrite 显示)。我可以使用shell命令:nc -l 5000 -u发现5000端口绝对没有数据。但是如果我运行:
gst-launch-1.0 -v videotestsrc ! video/x-raw,format=YUY2,width=640,height=480 ! jpegenc ! rtpjpegpay ! udpsink host=127.0.0.1 port=5000
然后shell命令显示端口上的数据。诊断问题的下一步是什么?谢谢!
系统:Nvidia Jetson TX1
【问题讨论】:
-
刚找到参数:! fakesink转储=真!所以现在使用管道: -vvv appsrc !视频转换!杰佩根! fakesink dump=TRUE 我正在获取数据。不过 udp 仍然一无所获...
-
我怀疑这可能与您正在做的事情有关。我想知道哪些过滤器应用于帧以及进行了哪些图像处理。如果您想了解更多信息,我发布了一个问题。 stackoverflow.com/questions/47848575/…
标签: c++ linux opencv gstreamer