Ask Your Question

tyutyuginslava's profile - activity

2015-06-09 18:29:18 -0600 commented question Opencv conflict namedWindow() and sscanf()

Thank you. I began to use version 3.0.0. It was working!

2015-06-04 18:05:14 -0600 received badge  Enthusiast
2015-05-31 17:42:27 -0600 commented question Opencv conflict namedWindow() and sscanf()

I use OS Ubuntu 14.04 with OpenCV 2.4.9 and do not use QT. Whether it was fixed in version 2.4.11?

2015-05-31 01:00:04 -0600 asked a question Opencv conflict namedWindow() and sscanf()

Hello! I have a problem when sharing cv::namedWindow() or cv::imshow() with sscanf() and strtod(). If sscanf() is above namedWindow(), it works fine, but if you put the after cv::namedWindow(), all numeric values are rounded off to whole numbers. Please help solve this problem!

a working script:

#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <stdio.h>

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

//example 1
    std::string data="20.911111111";
    double value;
    value = strtod(data.c_str(), NULL);
    std::cout<<value<<'\n';


//example 2
    char szOrbits[] = "365.24 29.53";
    char* pEnd;
    double d1, d2;
    sscanf(szOrbits, "%lf %lf" , &d1, &d2 );
    printf ("The moon completes %.2f orbits per Earth year.\n", d1/d2);

    cv::namedWindow( "test1", 0);

    return 0;
}

---------------result----------------------

20.9111

The moon completes 12.37 orbits per Earth year.


a non-working script:

#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <stdio.h>

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


     cv::namedWindow( "test2", 0);

//example 1
    std::string data="20.911111111";
    double value;
    value = strtod(data.c_str(), NULL);
    std::cout<<value<<'\n';


//example 2
    char szOrbits[] = "365.24 29.53";
    char* pEnd;
    double d1, d2;
    sscanf(szOrbits, "%lf %lf" , &d1, &d2 );
    printf ("The moon completes %.2f orbits per Earth year.\n", d1/d2);



    return 0;
}

---------------result----------------------

20

The moon completes inf orbits per Earth year.