简体   繁体   English

您如何通过Netcat将树莓派相机V2素材流式传输到OpenCV C ++

[英]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需要显示一个框架,并且在我的代码中没有为“图像”赋值的地方

  1. In order to recieve output from a stream I have to get it frame by frame, I cant just show the whole stream 为了从流中接收输出,我必须逐帧获取它,我不能只显示整个流

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.

相关问题 如何在c ++ openCV中使用raspberry pi摄像头作为视频输入? - how to use the raspberry pi camera as video input in c++ openCV? Raspberry Pi Opencv-3.2.0 Facedetect C ++示例找不到Raspberry Pi相机 - Raspberry Pi Opencv-3.2.0 facedetect C++ sample can't find Raspberry Pi camera 如何在Raspberry Pi上将OpenCV与C ++一起使用来加载视频文件? - How to a load video file by using OpenCV with C++ on Raspberry Pi? 在树莓派 2 上使用 opencv C++ - Use opencv C++ on raspberry pi 2 OpenCV树莓派3视频播放C ++ - Opencv raspberry pi 3 video play c++ 是否有可能在c ++中使用Raspberry Pi相机v4l2获得良好的FPS? - Is it possible to get good FPS using Raspberry Pi camera v4l2 in c++? 在Raspberry Pi上编译c ++ opencv应用程序时出错 - error compiling c++ opencv application on Raspberry Pi Opencv:无法打开显示:C ++,Raspberry Pi无头连接 - Opencv : Cannot open display : C++, Raspberry Pi Headless connection 如何在Raspberry Pi中使用Basler GigE相机pylon5 c ++库 - How to use Basler GigE camera pylon5 c++ libraries in Raspberry Pi 如何在决策条件下使用对象检测边界框来使用C ++ OpenCV打开Raspberry Pi上的LED? - How to use the Object Detection Bounding Box in a decision condition to turn on the LED on Raspberry Pi using C++ OpenCV?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM