Ask Your Question

Peter645's profile - activity

2017-09-22 07:34:53 -0600 received badge  Famous Question (source)
2017-02-24 06:29:02 -0600 received badge  Notable Question (source)
2017-01-06 00:31:18 -0600 received badge  Popular Question (source)
2015-07-16 03:31:20 -0600 asked a question Live stream to OpenCV via IP camera?

Okay so ultimately I am trying to write an accurate multiple person counting program using OpenCV and Visual Studio 2010. I am quite an OpenCV and C++ newbie so please be quite specific in the responses if possible.

I have recently acquired a Dahua IP camera which I have successfully set up, by set up I mean that I can access the live stream over the internet, and can also access it with OpenCV's video capture class, PROVIDED THAT I USE HTTP PROTOCOL with this URL:

"http://admin:[email protected]:80/cgi-bin/snapshot.cgi?chn=0&u=admin&p=admin&.mjpg"

My problem is this: I can access the stream from my Source.cpp. The code is below:


#include <iostream>
#include <opencv\highgui.h>
#include "opencv2/imgproc/imgproc.hpp" 
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;

int main(int argc, char* argv[])
{
    while (1)
    {
    VideoCapture cap("http://admin:[email protected]:80/cgi-bin/snapshot.cgi?chn=0&u=admin&p=admin&.mjpg"); // open the video camera using http protocol with the URL specified 
    //192.168.1.108 //Just the camera's IP address, I have changed my computers IP to coincide with this.

    if (!cap.isOpened())  // if not success, exit program
    {
        cout << "Cannot open the video cam" << endl;
        cin.get();
    cin.get();
        return -1;
    }
   cap.set(CV_CAP_PROP_FPS,25); // Feed is already 25fps, I tried setting it to a lower value but nothing      changes.
   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

   cout << "Frame size_1 : " << dWidth << " x " << dHeight << endl; //displays dimensions in console window, displays: "Frame size_1 : 1280 x 720" continuously

   cap.set(CV_CAP_PROP_FRAME_WIDTH, 640); //My attempts to change the frame size, pretty futile
   cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480);

   dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); 
   dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); ////get the width of frames of the video, change dwidth and dheight to these dimension, I expected them to be set to 640 and 480 respectively but it doesn't seem that way. 
   cout << "Frame size_2 : " << dWidth << " x " << dHeight << endl; //Still spitting out: "Frame size_2: 1280 x 720" continuously.

    namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo"


        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;
             cin.get();
    cin.get();
             break;
        }

        imshow("MyVideo", frame); //shows the frame in "MyVideo" window

        if (waitKey(30) == 27) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
       {
            cout << "esc key is pressed by user" << endl;
            break; 
       }
    }

    return 0;

So, with the above code I am able to open the stream from my IP camera. My first problem is that I cannot manipulate the feed (set the frame dimensions etc).

My BIGGER problem is that I cannot open the stream in my actual counting program in order to do image processing on it ...

(more)
2015-07-15 09:12:00 -0600 received badge  Critic (source)
2015-07-13 07:35:31 -0600 asked a question How to capture live stream from ION Air Pro Plus HD Camera?

I am doing a project regarding image processing and people counting and was wondering, how exactly can I plug my ION AIR PRO PLUS video recording device (similar to a goPro), and use it as my 'webcam'? Basically, I want to plug it in and then access it via a live feed using Microsoft Visual Studio 2010 and OpenCV. Anyone know how to do this?