cv::namedWindow changes fscanf parameters, how to prevent this ?
First i have to say that i am french and unlike english, french write 2,5 instead of 2.5. Yet in programmation, I more likely to use english rules. I have a program who need to
- read file with english rules : two int and two double
- use opencv
As you can see in the main.cpp, i do this :
- First I read my file : no problem
- Second I open the VideoCapture and creat windows : no problem
- Third I read again my file : huge problem i do not have the good result, I need to have a file write with the french rules!! (8 1175 0,176259 3,981072)
I can not change my file every time and i need to stay in french or in english (i have a preference for english). What may I do to change this?
readingFile.dat
8 1175 0.176259 3.981072
main.cpp #include <iostream> #include <cstdio> #include <opencv2 highgui="" highgui.hpp=""> #include <opencv2 imgproc="" imgproc.hpp="">
int initCam(cv::VideoCapture * cap) {
/***initialization of cap ***/
cap = new cv::VideoCapture(CV_CAP_OPENNI);
cap->open(CV_CAP_OPENNI);
if( !cap->isOpened() )
{
std::cout << "***Could not initialize capturing...***"<<std::endl;
return EXIT_FAILURE;
}
/*** initialization of windows ***/
cv::namedWindow("depth map", 0);
cv::namedWindow("image", 0);
return EXIT_SUCCESS;
}
int readFile( const char * name) {
int tabInt[2];
double tabDouble[2];
/*** open a file with english notation ***/
FILE *f = fopen(name, "r");
if (!f) return EXIT_FAILURE;
/*** read elements (int and double) ***/
fscanf(f, "%d", tabInt );
fscanf(f, "%d", tabInt+1);
fscanf(f, "%lf", tabDouble);
fscanf(f, "%lf", tabDouble+1);
/*** print elements ***/
std::cout<<"integer table : " << tabInt[0] <<"\t"<< tabInt[1]<<std::endl;
std::cout<<"double table : " << tabDouble[0] <<"\t"<< tabDouble[1]<<std::endl;
}
int main(void) {
cv::VideoCapture * cap;
std::string file = "readingFile.dat";
std::cout<<"reading before creating OpenCv windows : "<<std::endl;
readFile(file.c_str());
initCam(cap);
std::cout<<"reading after creating OpenCv windows : "<<std::endl;
readFile(file.c_str());
}
result :
reading before creating OpenCv windows :
integer table : 8 1175
double table : 0.176259 3.98107
init done
opengl support available
reading after creating OpenCv windows :
integer table : 8 1175
double table : 0 1.09022e-312
ok, so namesWindow changes tje locale on your box.
could you add, which os / gui you're using ?
I am using Linux in centos