Ask Your Question

Florence's profile - activity

2020-09-16 03:28:35 -0600 received badge  Notable Question (source)
2018-08-02 01:42:43 -0600 received badge  Famous Question (source)
2018-02-28 13:34:35 -0600 received badge  Popular Question (source)
2017-10-07 19:16:45 -0600 received badge  Notable Question (source)
2017-05-16 05:06:02 -0600 received badge  Popular Question (source)
2016-06-07 02:31:03 -0600 commented answer parser.has() alway retruning true

Hello,

After your answer I tried to rewrite the same programm in a other file, and it worked... I looked in the previous one if there were hidden characters that may have cause a problem, and I couldn´t find anything...

So thanks a lot for your answer, problem solved I guess :)

2016-06-03 07:45:34 -0600 asked a question parser.has() alway retruning true

Hello,

I´m trying to use CommandLineParser and I have a problem : even if I don´t put anything when I lauch the program (only ./prog ), the function parser.has returns true, as if something was given on the command line.

If someone has an idea of what I am doing wrong, it would be very helpful !

Thanks :)

Here is the code :

const char* keys =
    {
        "{help          |                   | show help message }"
        "{type          |                   | type of the camera}"
        "{camera_number |                   | camera number     }"
    };


int main(int argc, char* argv[])
{

        CommandLineParser parser(argc, argv, keys);

        bool t = parser.has("type");
        cout << " t = " << t << endl;

        bool cm = parser.has("camera_number"); 
        cout << "cm = " << cm << endl; 

        return 0;
}
2016-05-23 08:25:13 -0600 answered a question Cannot identify device '/dev/video0' - video reading OpenCV 3.1

Problem solved : It was a special camera, and it needed a particular software (ximea in my case) to work. It didn´t appear as a video device.

2016-05-23 08:16:32 -0600 asked a question Negative values in flow matrix with calcOpticalFlowSF

Hello,

I´m trying to use the optical flow functions of opencv, and in particular calcOpticalFlowSF.

The matrix I get has negative and float numbers - so the imshow function in the program below crashs. Does anyone has an idea why ?

Thanks a lot !

#include "opencv2/optflow.hpp"
#include <opencv2/core/utility.hpp>
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"

#include <cstdio>
#include <iostream>

using namespace cv;
using namespace cv::optflow;
using namespace std;



int main(int argc, char** argv)
{

  if (argc < 3) {
    cout << "missing arguments" << endl;
    exit(1);
  }

  cout << argv[0] << endl;

  Mat frame1 = imread(argv[1]);
  Mat frame2 = imread(argv[2]);

  if (frame1.empty()) {
    cout << "frame 1 cannot be read" << endl; 
    exit(1);
  }

  if (frame2.empty()) {
    cout << "frame 2 cannot be read" << endl; 
    exit(1);
  }

  if (frame1.rows != frame2.rows && frame1.cols != frame2.cols) {
    cout << "Images should be of equal sizes" << endl;
    exit(1);
  }

 if (frame1.type() != 16 || frame2.type() != 16) {
    cout <<"Images should be of equal type CV_8UC3" << endl;
   exit(1);
  }


  cout << "images read" << endl;

  Mat flow;

  //calcOpticalFlowSF(frame1, frame2, flow,3, 2, 4, 4.1, 25.5, 18, 55.0, 25.5, 0.35, 18, 55.0, 25.5, 10);
    calcOpticalFlowSF(frame1, frame2, flow,3, 2, 4);




  imshow("Optical Flow" , flow);
  waitKey(0);

  return 0 ;
}
2016-04-26 02:47:06 -0600 commented question Cannot identify device '/dev/video0' - video reading OpenCV 3.1

No there are no new devices when I plug the camera... But when I type dmesg then I see that the usb device is connected and recognized. And no, no virtual machine.

2016-04-26 01:59:15 -0600 commented question Cannot identify device '/dev/video0' - video reading OpenCV 3.1

Oh you're right, it actually doesn't exist. But I'm sure the camera is connected and recognized by the computer. I've also tried to replace VideoCapture cap(0) by VideoCapture cap(CV_CAP_XIAPI) which actually works better as it doesn't crach, but the video cannot be opened...

2016-04-25 08:22:58 -0600 received badge  Editor (source)
2016-04-25 08:17:11 -0600 asked a question Cannot identify device '/dev/video0' - video reading OpenCV 3.1

Hello,

I'm trying read the video from a camera connected to my computer using OpenCV.

I tried this first test, and I got the following error message :

"GStreamer Plugin: Embedded video playback halted; module v4l2src0 reported: Cannot identify device '/dev/video0'. OpenCV Error: Unspecified error (GStreamer: unable to start pipeline ) in cvCaptureFromCAM_GStreamer, file 'file_location'/opencv-3.1.0/modules/videoio/src/cap_gstreamer.cpp, line 818 terminate called after throwing an instance of 'cv::Exception' what(): 'file_location'/opencv-3.1.0/modules/videoio/src/cap_gstreamer.cpp:818: error: (-2) GStreamer: unable to start pipeline in function cvCaptureFromCAM_GStreamer

Aborted"

Here is the code :

   #include "opencv2/opencv.hpp"
#include <stdio.h>

using namespace cv;

int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
    {
        std::cout << " Cannot open video" << std::endl;
        return -1;
    }

    Mat edges;
    namedWindow("edges",1);
    for(;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, COLOR_BGR2GRAY);
        GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
        Canny(edges, edges, 0, 30, 3);
        imshow("edges", edges);
        if(waitKey(30) >= 0) break;
    }
    // the camera will be deinitialized automatically in VideoCapture destructorcd ,,
    return 0;
}

If someone has an idea that would be very helpful !

Thank you very much in advance.

Florence

2016-04-15 03:23:18 -0600 commented answer Error with createBackgroundSubtractor with OpenCV 3.1 and extra module contrib

Great it works like a charm ! Thank you very much !

2016-04-15 03:18:04 -0600 received badge  Scholar (source)
2016-04-15 03:18:03 -0600 received badge  Supporter (source)
2016-04-14 07:48:43 -0600 asked a question Error with createBackgroundSubtractor with OpenCV 3.1 and extra module contrib

Hello !

I just installed opencv 3.1, and I wanted to use the function createBackgroundSubtractorMOG. I saw on this post that it was moved to an extra module, so I installed it ( post : http://answers.opencv.org/question/88... ), but I still have a problem. Indeed when I compile, I have the following error :
"error: ‘createBackgroundSubtractorMOG’ was not declared in this scope"

And when I try to write : bgsegm::createBackgroundSubtractorMOG, I got : undefined reference tocv::bgsegm::createBackgroundSubtractorMOG(int, int, double, double)

If someone has a idea why I still can't use this function, that would be very helpful !

Here is the code (it is actually the code from http://docs.opencv.org/3.1.0/d1/dc5/t... , where I changed MOG2 to MOG)

Thank you very much !

Florence

    //opencv
    #include "opencv2/imgcodecs.hpp"
    #include "opencv2/imgproc.hpp"
    #include "opencv2/videoio.hpp"
    #include <opencv2/highgui.hpp>
    #include <opencv2/video.hpp>
    #include <opencv2/core/ocl.hpp>
  #include <opencv2/bgsegm.hpp>
  #include <opencv2/core.hpp>
    //C
    #include <stdio.h>
    //C++
    #include <iostream>
    #include <sstream>
    using namespace cv;
    using namespace std;
    // Global variables
    Mat frame; //current frame
    Mat fgMaskMOG; //fg mask fg mask generated by MOG method
    Ptr<BackgroundSubtractor> pMOG; //MOG Background subtractor
    int keyboard; //input from keyboard
    void help();
    void processVideo(char* videoFilename);
    void processImages(char* firstFrameFilename);
    void help()
    {
        cout
        << "--------------------------------------------------------------------------" << endl
        << "This program shows how to use background subtraction methods provided by "  << endl
        << " OpenCV. You can process both videos (-vid) and images (-img)."             << endl
                                                                                        << endl
        << "Usage:"                                                                     << endl
        << "./bs {-vid <video filename>|-img <image filename>}"                         << endl
        << "for example: ./bs -vid video.avi"                                           << endl
        << "or: ./bs -img /data/images/1.png"                                           << endl
        << "--------------------------------------------------------------------------" << endl
        << endl;
    }

        int main(int argc, char* argv[])
    {

    //print help information
        help();

        // desactivate the parallelism on the gpu
        cv::ocl::setUseOpenCL(false);

        //check for the input parameter correctness
        if(argc != 3) {
            cerr <<"Incorret input list" << endl;
            cerr <<"exiting..." << endl;
            return EXIT_FAILURE;
        }
        //create GUI windows
        namedWindow("Frame");
        namedWindow("FG Mask MOG 2");
        //create Background Subtractor objects
        pMOG = createBackgroundSubtractorMOG(); //MOG approach
        if(strcmp(argv[1], "-vid") == 0) {
            //input data coming from a video
            processVideo(argv[2]);
        }
        else if(strcmp(argv[1], "-img") == 0) {
            //input data coming from a sequence of images
            processImages(argv[2]);
        }
        else {
            //error in reading input parameters
            cerr <<"Please, check the input parameters." << endl;
            cerr <<"Exiting..." << endl;
            return EXIT_FAILURE;
        }
        //destroy GUI windows
        destroyAllWindows();
        return EXIT_SUCCESS;
    }
    void processVideo(char* videoFilename) {
        //create the capture object
        VideoCapture capture(videoFilename);
        if(!capture.isOpened()){
            //error in opening the video input
            cerr << "Unable to open video file: " << videoFilename << endl;
            exit(EXIT_FAILURE);
        }
        //read input data. ESC or 'q' for quitting
        while( (char)keyboard != 'q' && (char)keyboard != 27 ){
            //read the current frame
            if(!capture.read(frame)) {
                cerr << "Unable to read next frame." << endl;
                cerr << "Exiting..." << endl;
                exit(EXIT_FAILURE);
            }
            //update the background model
            pMOG->apply(frame, fgMaskMOG,1);
            //get the frame number and write it on the current frame
            stringstream ss;
            rectangle(frame, cv::Point(10, 2), cv::Point(100,20),
                      cv::Scalar(255,255,255), -1);
            ss << capture.get(CAP_PROP_POS_FRAMES);
            string frameNumberString = ss.str();
            putText(frame, frameNumberString ...
(more)