[英]How do you stream raspberry pi camera V2 footage via netcat to OpenCV C++
Edit: I rewrote the code I copied and now it receives the stream successfully however when the code reaches namedWindow I get no output or sometimes "Aborted" at the end of my string 编辑:我重写了我复制的代码,现在它成功接收到流,但是当代码到达namedWindow时,我没有输出,或者有时在字符串的末尾出现“异常终止”
error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow' 错误:(-215:断言失败)函数'imshow'中的size.width> 0 && size.height> 0
My PC: a debian virtualbox machine 我的电脑:一台debian虚拟机
note: Thee stuff in < > is replaced with my ip address 注意:<>中的内容已替换为我的IP地址
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv )
{
VideoCapture vcap;
Mat image;
const string videoStreamAddress = "udp://<myIp>:<port>";
vcap.open("udp://<myIp>:<port>");
if(!vcap.isOpened())
{
printf("nope");
}
else
{
printf("sucsess");
namedWindow("stuff", WINDOW_NORMAL);
imshow("stuff", image);
}
}
what my raspberry pi executes:
/opt/vc/bin/raspivid -t 0 -w 300 -h 300 -hf -fps 20 -o - | / opt / vc / bin / raspivid -t 0 -w 300 -h 300 -hf -fps 20 -o-| nc IpAddressInCode PortInCode nc IpAddressInCode PortInCode
Ok so apparently the problem was 好吧,显然问题是
1.ImShow Requires a frame to show and No where in my code did I assign "image" a value 1.ImShow需要显示一个框架,并且在我的代码中没有为“图像”赋值的地方
error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow' 错误:(-215:断言失败)函数'imshow'中的size.width> 0 && size.height> 0
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main(int argc, char** argv )
{
VideoCapture vcap;
const string videoStreamAddress = "udp://<myIp>:<myPort>";
vcap.open(videoStreamAddress);
if(!vcap.isOpened())
{
printf("nope");
}
else
{
for(;;)
{
Mat frame;
vcap >> frame;
imshow("stuff", frame);
if( waitKey(10) == 27) break;
}
printf("Sucsess!");
}
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.