Ask Your Question
0

Using capVideo.read(img) VS capvideo >> img

asked 2017-12-28 11:41:32 -0600

calocabe96 gravatar image

I'm trying to display a live stream video of an IP camera in my raspberry Pi. What I want to know is the difference of using capVideo.read(img) instead capVideo >> img. My program is in C++.

using namespace cv;
using namespace std;

int main(){
    Mat frame;
    VideoCapture cap("rtsp://ipofmycamera/11");
    while(cap.isOpened()){

        cap >> frame; // cap.read(frame)
        if(frame.empty()) {
            cout << "no frame" << endl;
            break;
        }
        imshow("video", frame);
        if(waitKey(30) >= 0) break;

    }

}

edit retag flag offensive close merge delete

Comments

VideoCapture cap("rtsp://ipofmycamera:554/11"); Use 554 as port for default or any numbers...such as 8080 or 1234, etc. I'm using rapi 3 and python 3.5

supra56 gravatar imagesupra56 ( 2018-01-01 08:18:42 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-12-28 12:08:25 -0600

berak gravatar image

updated 2017-12-28 15:19:43 -0600

there is no real difference (apart from read() also returning an error value (which you should actually check, it's there for a reason !)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-12-28 11:41:32 -0600

Seen: 801 times

Last updated: Dec 28 '17