我有一台通过USB连接到NVIDIA TX1的Logitech C920相机。我想在OpenCV中做一些计算机视觉时,将rtsp上的摄像头馈送到服务器。我设法从Opencv中的usb相机读取H264视频
#include <iostream>
#include "opencv/cv.h"
#include <opencv2/opencv.hpp>
#include "opencv/highgui.h"
using namespace cv;
using namespace std;
int main()
{
Mat img;
VideoCapture cap;
int heightCamera = 720;
int widthCamera = 1280;
// Start video capture port 0
cap.open(0);
// Check if we succeeded
if (!cap.isOpened())
{
cout << "Unable to open camera" << endl;
return -1;
}
// Set frame width and height
cap.set(CV_CAP_PROP_FRAME_WIDTH, widthCamera);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, heightCamera);
cap.set(CV_CAP_PROP_FOURCC, CV_FOURCC('X','2','6','4'));
// Set camera FPS
cap.set(CV_CAP_PROP_FPS, 30);
while (true)
{
// Copy the current frame to an image
cap >> img;
// Show video streams
imshow("Video stream", img);
waitKey(1);
}
// Release video stream
cap.release();
return 0;
}
我还使用ffmpeg将USB摄像头传输到rtsp服务器:
ffmpeg -f v4l2 -input_format h264 -timestamps abs -video_size hd720 -i /dev/video0 -c:v copy -c:a none -f rtsp rtsp://10.52.9.104:45002/cameraTx1
我试图谷歌如何结合这两个功能,即在openCV中打开USB摄像头并使用openCV来传输H264 rtsp视频。但是,我能找到的只是人们试图在openCV中打开rtsp流。
有没有人使用openfV和ffmpeg成功传输H264 rtsp视频?
祝你好运 松德雷