IP摄像机使用rstp,Visual Studio OpenCv 2.4.5进行访问? [英] IP camera acessing using rstp, visual studio OpenCv 2.4.5?

查看:142
本文介绍了IP摄像机使用rstp,Visual Studio OpenCv 2.4.5进行访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是用于使用lan端口访问我的IP摄像头的代码。 (第一个代码工作正常)。我需要的是使用Mat(C ++)结构获取图像。代码2显示了我使用Mat结构所做的工作,但是当我调试程序时,执行cv :: namedWindow(Frame);然后打破代码,发出一个Unhandled异常,显示如下。

我的最终要求 是使用Mat而不是iplimage来完成这项工作。提示或适当的代码会很棒,因为我正在使用HOG进行人体检测项目。谢谢。

This is the code used to access my IP camera using lan port. (first code works fine). What I need is to get image with Mat(C++) structure. Code number 2 shows what I have done to using Mat structure but when I debug the program, execute cv::namedWindow("Frame"); and then breaks the code giving out an Unhandled exception which shows bellow.
My Final requirement is to get this job done using Mat instead of iplimage. tip or an appropriate code would be great since I am doing a project on Human detection using HOG. thanks.

#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 null\n");
    else
        printf("camera is not null");

    cvNamedWindow("img");
    while (cvWaitKey(10)!=atoi("q")){
      
        IplImage *img=cvQueryFrame(camera);
        cvShowImage("img",img);
    }
    cvReleaseCapture(&camera);
}










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;
}





错误:

使用Web cam.exe在Hog中的0x00660598处未处理的异常: 0xC0000005:访问冲突读取位置0xcccc0065。



Error:
Unhandled exception at 0x00660598 in Hog with Web cam.exe: 0xC0000005: Access violation reading location 0xcccc0065.

推荐答案

您可能必须删除您的cv :: Ptr时间点。
You probably have to delete your cv::Ptr at some point of time.


为什么不使用如下所示的VideoCapture:

http://stackoverflow.com/questions/712998/opencv-with-network-cameras [ ^ ]
Why not use VideoCapture as shown here:
http://stackoverflow.com/questions/712998/opencv-with-network-cameras[^]


这篇关于IP摄像机使用rstp,Visual Studio OpenCv 2.4.5进行访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆