Ask Your Question

mistermystere's profile - activity

2020-09-15 08:42:13 -0500 received badge  Popular Question (source)
2020-04-13 13:03:07 -0500 commented question cv2.imshow() doesn't work when I remove cv2.watKey(0) after it

cv2.waitKey(1) will have negligible impact and will do what you want

2020-04-12 18:10:24 -0500 edited question Drawing checkerboard's reference frame does not yield correct results (solvePnp+projectPoints)

OpenCV solvePnP does not yield correct results Greetings, I have followed the tutorial at

2020-04-12 15:55:25 -0500 asked a question Drawing checkerboard's reference frame does not yield correct results (solvePnp+projectPoints)

OpenCV solvePnP does not yield correct results Greetings, I have followed the tutorial at

2016-12-05 06:41:34 -0500 received badge  Famous Question (source)
2016-03-16 09:05:17 -0500 received badge  Notable Question (source)
2015-10-27 08:51:02 -0500 received badge  Popular Question (source)
2013-05-08 16:39:53 -0500 received badge  Editor (source)
2013-05-08 16:38:25 -0500 asked a question cv::VideoCapture works for webcams but not IP cameras

It had to happen, I'm stuck in the last phase of my project, when I want to use my code which works like a charm on my webcam, on an IP camera. The URL works perfectly in my browser, but nothing comes out with OpenCV... Here is my code:

#include <opencv/highgui.h>

using namespace cv;

int main(int argc, char *argv[])
    Mat frame;
    namedWindow("video", 1);
    VideoCapture cap("");
    while ( cap.isOpened() )
        cap >> frame;
        if(frame.empty()) break;

        imshow("video", frame);
        if(waitKey(30) >= 0) break;

    return 0;

And the compiler settings :

//Added to the .pro file of QtCreator
INCLUDEPATH += C:\\OpenCV243\\release\\include
LIBS += -LC:\\OpenCV243\\release\\lib \
    -lopencv_core243.dll \

I've tested opening a .avi file with the same code and it works... But a public IP camera URL like doesn't ! What's the matter then ?

Thanks for your help,

Regards, Mister Mystère

2013-05-06 13:27:25 -0500 commented answer Delay voluntarily a live feed from a VideoCapture

I have a buffer for each camera so that should be fine for this. Well I'd be glad to share a code that worked for me using simply cv::Mat::clone() but I'm not allowed to answer my own question before 2 days so I'll post later. In the meantime I'm still looking for an explanation for having and a solution for avoiding tuning the timer to the actual FPS of the camera... Because otherwise I get an increase in the desired lag by up to 50% (at 30 fps instead of 23fps with which I have 10%) !

2013-05-06 05:00:03 -0500 commented answer Delay voluntarily a live feed from a VideoCapture

Merci de votre réponse ;) I'm particularly interested in the first solution since it's a very simple one (I have quite a tight schedule). So I would need to grab an image in my timerEvent (so once every 35ms), and in that very method, as soon as a counter reaches delay*fps start retrieving at each call ? (I can't compile here for now) One important issue is the size of the buffer. I'll be dealing with delays up to 2 seconds (hence 60 frames in VGA)... Is it limited somehow ? Edit: Hmm, sounds like this solution would not allow for 2 cameras without some extra work around it. I saw cv::Mat::clone(), seems to answer my question doesn't it?

2013-05-06 03:49:27 -0500 asked a question Delay voluntarily a live feed from a VideoCapture


I have a class Camera inheriting from cv::VideoCapture, which its core method is to convert a cv::Mat that I get from a live stream to a QImage :

QImage Camera::getFrame() {
    if(isOpened()) {
        cv::Mat image;
        (*this) >> image;
        cv::cvtColor(image, image, CV_BGR2RGB);
        return QImage((uchar*), image.cols, image.rows, image.step, QImage::Format_RGB888);
    else return QImage();

And an encapsulating class CameraDelayedView which calls this method and adds a delay :

void CameraDelayedView::timerEvent(QTimerEvent *evt) {
    if(cam != NULL) {

        if(buffer.size() > delay*fps) {

The first frame is delayed like I want, but from that moment on, the video is a normal live feed like I would get without the queue system. Apparently, the images are part of a buffer which is updated, so that when creating a QImage with, the pointers point at a frame which will be updated afterward. I want to avoid that: keep a snapshot, store it.

Do I have to copy each myself to make it independant, or is there a more efficient way ? Please do not hesitate to tell me if the above can be more efficient as well.

Thanks in advance.

Regards, Mister Mystère

2013-05-06 03:41:35 -0500 commented answer Control PTZ

Thank you for your answer. I ended up sniffing the communication port with WireShark for HTTP requests in order to get what the commands were because I couldn't find any API for this camera. Works like a charm :)

2013-05-06 03:40:22 -0500 received badge  Scholar (source)
2013-05-06 03:40:17 -0500 received badge  Supporter (source)
2013-05-02 03:10:20 -0500 received badge  Student (source)
2013-05-01 06:48:23 -0500 asked a question Control PTZ


I will soon be using OpenCV for retrieving a live feed from my Wanscam, but I don't know how to control the pan and tilt functionalities (C++), which are yet vital to my project.

I couldn't find it in OpenCV's doc. Is it really absent from the API ? If so, would you happen to know how I could achieve this please ?

Thanks in advance.

Regards, Mister Mystère