IP摄像机访问使用rtsp, visual studio OpenCv 2.4.5
IP camera acessing using rtsp, visual studio OpenCv 2.4.5?
这是使用lan端口访问我的IP摄像机的代码。(第一个代码工作正常)。我需要的是得到图像与Mat(c++)结构。代码2显示了我使用Mat结构所做的事情,但是当我调试程序时,执行cv::namedWindow("Frame");然后中断代码,给出如下所示的未处理异常。我的最后一个要求是使用Mat而不是iplimage完成这项工作。提示或适当的代码将是伟大的,因为我正在做一个项目在人类检测使用HOG。谢谢。
#include "stdafx.h"
#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <stdio.h>
#include "opencv.hpp"
int main(){
CvCapture *camera=cvCaptureFromFile("rtsp://192.168.1.19:554/0/1:1/main");
if (camera==NULL)
printf("camera is nulln");
else
printf("camera is not null");
cvNamedWindow("img");
while (cvWaitKey(10)!=atoi("q")){
IplImage *img=cvQueryFrame(camera);
cvShowImage("img",img);
}
cvReleaseCapture(&camera);
}
代码2:
int main(int argc, char* argv[])
{
cv::Ptr<CvCapture> capture = cvCaptureFromFile("rtsp://192.168.1.19:554/0/1:1/main");
cv::namedWindow("Frame");
for (;;)
{
cv::Mat frame = cvQueryFrame(capture);
cv::imshow("Frame", frame);
if (cv::waitKey(1) >= 0)
break;
}
return 0;
}
例外:在Hog与Web cam.exe中的0x00660598未处理的异常:0xC0000005:访问违反读取位置0xcccc0065。
是啊,扔掉那该死的c-api !
int main(int argc, char* argv[])
{
cv::namedWindow("Frame");
cv::VideoCapture capture("rtsp://192.168.1.19:554/0/1:1/main");
while ( capture.isOpened() ) // check !!
{
cv::Mat frame;
if ( ! capture.read(frame) ) // another check !!
break;
cv::imshow("Frame", frame);
if (cv::waitKey(1) >= 0)
break;
}
return 0;
}
相关文章:
- Visual Studio C++找不到 OpenCV-Contrib 模块
- OpenCV 3 Visual Studio 2017 调试,调用堆栈没有.pdb文件
- 为什么在Visual Studio的OpenCV项目中使用/MT时仍然需要dll?
- 如何在Visual Studio中添加OpenCV文件
- 在Visual "Microsoft studio 2019"上设置OpenCV 4.1.1时遇到问题?(非法指令。
- opencv 3.0 Visual Studio Community 2017 编译链接错误
- 在visual code studio中找不到opencv(用于ubuntu中的c++)
- Visual Studio 2017在我将鼠标移到Mat关键字(OpenCv 3.4.1)上时冻结
- opencv aruco.h not found windows 10 visual studio
- 在所有程序中,在Visual Studio中添加OpENCV的一般方法是什么?
- 错误 LNK2019: 未解析的外部符号 Visual Studio 2013 与 openCV
- cv:内存位置的异常 - 运行 openCV 代码 Visual Studio 2013 & Visual Studio 2017 - Windows 7
- 使用Visual Studio项目使Opencv可移植,并删除链接错误
- 我是否需要Microsoft Visual Studio/Eclipse才能使用opencv等库进行C++编码?
- Visual Studio 中 Opencv 的介绍性示例程序以代码 -1 退出.不放心
- 如何在 OPENCV 3.x C++ Visual Studio 2015 中声明 BruteForceMatcher
- 自动驾驶汽车 Android "opencv.dir"未在本地媒体资源中设置 - Android Studio
- 在Android Studio中使用NDK GrabCut返回的OpenCV总是黑色面具
- Visual Studio 2015 OpenCV Assertion 在 cv::imshow windows 中失败 (size.width>0 && size.height>0.cp
- OpenCV Webcam 源未显示在 PictureBox visual studio 2015 中