【发布时间】:2015-05-26 04:45:43
【问题描述】:
我目前正在从事一个从网络摄像头捕获视频并通过 UDP 发送编码流以进行实时流式传输的项目。
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
VideoCapture cap(0); // open the video camera no. 0
double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video
while (1)
{
Mat frame;
bool bSuccess = cap.read(frame); // read a new frame from video
if (!bSuccess) //if not success, break loop
{
cout << "Cannot read a frame from video stream" << endl;
break;
}
return 0;
}
有人说从 cap.read(frame) 得到的帧已经是解码帧,我不知道这是怎么发生的,什么时候发生的。我想要的是编码的帧或流。我应该怎么做才能得到它?我应该重新编码吗?
【问题讨论】:
-
为什么不直接使用解码帧?
-
因为我们需要通过UDP发送,所以我们希望数据尽可能小,解码的比编码的大
-
如果你不能访问底层流来检查,你怎么知道它更小?在我看来,您最好研究如何对视频流进行转码。
标签: c++ opencv video-streaming webcam