Ask Your Question

valentine's profile - activity

2019-01-09 20:35:12 -0500 received badge  Popular Question (source)
2018-03-23 15:58:57 -0500 received badge  Notable Question (source)
2017-07-19 07:56:39 -0500 received badge  Popular Question (source)
2016-08-22 16:23:03 -0500 received badge  Critic (source)
2016-08-22 14:33:40 -0500 asked a question C++ implementation of codebook algorithm in opencv

Hi all, I noticed in the sample folder of opencv there C implementation of codebook algorithm for background subtraction. There is none for C++ as it replaced with MOG, MOG2 and GMG algorithms. I want to kindly is there a C++ implementation of the codebook algorithm.

Best Regards.

2016-08-15 10:28:54 -0500 received badge  Self-Learner (source)
2016-08-15 10:16:50 -0500 answered a question Error building opencv 2.4.13 with Qt mingw

Hey guys,

I found the major issue to this. When configuring opencv with mingw for Qt.5.x do not enable the "compile with Qt" option in cmake as this is only enabled for opencv with Qt.4.x. Just compiled like a charm.

Regards.

2016-08-09 08:25:39 -0500 asked a question Error building opencv 2.4.13 with Qt mingw

Dear All,

I am trying to configure OpenCV 2.4.13 with Qt MinGW. The config with CMAKE was successful, however, when I try to build with mingw32-make command I get the following error:

C:\opencv-2.4.13\opencv\sources\modules\highgui\src\window_QT.cpp:2539:9: note: in expansion of macro 'foreach' foreach (QAction a, centralWidget->vect_QActions) ^ C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtCore/qglobal.h:963:49: error: request for member 'control' in '_container_', which is of non-class type 'int' for (variable = *_container_.i; _container_.control; _container_.control = 0) ^ C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtCore/qglobal.h:971:21: note: in expansion of macro 'Q_FOREACH' # define foreach Q_FOREACH ^ C:\opencv-2.4.13\opencv\sources\modules\highgui\src\window_QT.cpp:2539:9: note: in expansion of macro 'foreach' foreach (QAction *a, centralWidget->vect_QActions) ^ C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtCore/qglobal.h:963:70: error: request for member 'control' in '_container_', which is of non-class type 'int' for (variable = *_container_.i; _container_.control; _container_.control = 0) ^ C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtCore/qglobal.h:971:21: note: in expansion of macro 'Q_FOREACH' # define foreach Q_FOREACH ^ C:\opencv-2.4.13\opencv\sources\modules\highgui\src\window_QT.cpp:2539:9: note: in expansion of macro 'foreach' foreach (QAction *a, centralWidget->vect_QActions) ^ C:\opencv-2.4.13\opencv\sources\modules\highgui\src\window_QT.cpp: In member fun ction 'void DefaultViewPort::controlImagePosition()': C:\opencv-2.4.13\opencv\sources\modules\highgui\src\window_QT.cpp:2748:21: error : ambiguous overload for 'operator=' (operand types are 'QTransform' and 'QTrans form') matrixWorld_inv = param_matrixWorld.inverted(); ^ In file included from C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtGui/qimage.h:47:0, from C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtGui/qpixmap.h:48, from C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtGui/qicon.h:46, from C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtWidgets/qabstractbu tton.h:43, from C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtWidgets/qpushbutton .h:43, from C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtWidgets/QPushButton :1, from C:/opencv-2.4.13/opencv/sources/modules/highgui/src/window _QT.h:53, from C:\opencv-2.4.13\opencv\sources\modules\highgui\src\window _QT.cpp:47: C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtGui/qtransform.h:79:17: note: candidate: QTransform& QTransform::operator=(QTransform) QTransform &operator=(QTransform &&other) Q_DECL_NOTHROW // = default ^ C:/Qt/Qt5.7.0/5.7/mingw53_32/include/QtGui/qtransform.h:81:17: note: candidate: QTransform& QTransform::operator=(const QTransform&) QTransform &operator=(const QTransform &) Q_DECL_NOTHROW; // = default ^ modules\highgui\CMakeFiles\opencv_highgui.dir\build.make:193: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_QT.cpp.obj' failed mingw32-make[2]: [modules/highgui/CMakeFiles/opencv_highgui.dir/src/window_Q T.cpp.obj] Error 1 CMakeFiles\Makefile2:2042: recipe for target 'modules/highgui/CMakeFiles/opencv_ highgui.dir/all' failed mingw32-make[1]: * [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2

Makefile:145 ... (more)

2016-04-27 10:15:00 -0500 answered a question Errors when predicting from a Neutral Network

Hi berak,

solved the problem using the same data. I basically removed the setMethod, setBackpropMomentumScale, setBackpropWeightscale, setTermCriteria and it worked. I dont know why but will like someone to explain. Here is the code below:

  int inputLayerSize = 2;
int outputLayerSize = 1;
int numSamples = 3;
int hiddenLayer = 3;
vector<int> layerSizes = { inputLayerSize,hiddenLayer, outputLayerSize };
Ptr<ml::ANN_MLP> nnPtr = ml::ANN_MLP::create();
nnPtr->setLayerSizes(layerSizes);
nnPtr->setActivationFunction(ANN_MLP::SIGMOID_SYM);
//nnPtr->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM);
/*nnPtr->setTrainMethod(ml::ANN_MLP::BACKPROP);
nnPtr->setBackpropMomentumScale(0.1);
nnPtr->setBackpropWeightScale(0.1);
nnPtr->setTermCriteria(TermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 100, 1e-4));*/

Mat samples(Size(inputLayerSize, numSamples), CV_32F);
samples.at<float>(Point(0, 0)) = 0.3f;
samples.at<float>(Point(1, 0)) = 1.0f;
samples.at<float>(Point(0, 1)) = 0.2f;
samples.at<float>(Point(1, 1)) = 0.2f;
samples.at<float>(Point(0, 2)) = 1.0f;
samples.at<float>(Point(1, 2)) = 0.4f;
Mat responses(Size(outputLayerSize, numSamples), CV_32F);
responses.at<float>(Point(0, 0)) = 0.75f;
//responses.at<float>(Point(0, 1)) = 0.64f;
responses.at<float>(Point(0, 1)) = 0.82f;
//responses.at<float>(Point(1, 1)) = 0.74f;
responses.at<float>(Point(0, 2)) = 0.93f;
//responses.at<float>(Point(2, 1)) = 0.84f;

cout << "samples:\n" << samples << endl;
cout << "\nresponses:\n" << responses << endl;

if (!nnPtr->train(samples, ml::ROW_SAMPLE, responses))
    return 1;
cout << "\nweights[0]:\n" << nnPtr->getWeights(0) << endl;
cout << "\nweights[1]:\n" << nnPtr->getWeights(1) << endl;
cout << "\nweights[2]:\n" << nnPtr->getWeights(2) << endl;
cout << "\nweights[3]:\n" << nnPtr->getWeights(3) << endl;

Mat output;
Mat samplestest(Size(inputLayerSize, 1), CV_32F);
samplestest.at<float>(Point(0, 0)) = 0.8f;
samplestest.at<float>(Point(1, 0)) = 0.6f;
//samplestest.at<float>(Point(0, 2)) = 0.3f;
nnPtr->predict(samplestest, output);
cout << "\noutput:\n" << output << endl;

and the output is given below:

samples: [0.30000001, 1; 0.2, 0.2; 1, 0.40000001]

responses: [0.75; 0.81999999; 0.93000001]

weights[0]: [2.809757458984826, -1.404878743448629, 2.941742042246543, -1.568929097965231]

weights[1]: [-0.2094534488630105, 0.5412198073856522, 1.658734440612611; -0.8916550488630105, -1.139978207385652, -0.7469871593873889; 0.7505247417458868, 0.7944425035100793, -0.1239852716789556]

weights[2]: [-0.3488449412441831; 0.8637626791966008; 1.178125967026814; -0.2092970630454225]

weights[3]: [0.09473684586976705, 0.8400000035762786]

output: [0.88864398]

2016-04-23 06:35:56 -0500 commented question Errors when predicting from a Neutral Network

hi berak this only error message Unhandled exception at 0x00007FFE0076855C (opencv_world310d.dll) in fetchvideoapp.exe: 0xC0000005: Access violation reading location 0x000001D3A69DF000.

2016-04-22 17:57:54 -0500 asked a question Errors when predicting from a Neutral Network

Hello everyone,

I am trying to train a neutral network in opencv using one hidden layer network. Everything seems fine but the program crashes when the predict function for the model is called. Below is my code:

float sc[6] = { 0.3, 0.5, 1, 1, 0.2, 0.4 };
float sc1[3] = { 0.75, 0.81, 0.93 };
float sc2[2] = { 0.2, 1};
Mat traindata = Mat(3,2,CV_32FC1,&sc);
Mat trainlabel = Mat(3, 1,CV_32FC1,&sc1);
Mat testdata = Mat(1, 2,CV_32FC1,&sc2);
Ptr<ml::ANN_MLP> mlp = ml::ANN_MLP::create();
mlp->setActivationFunction(ml::ANN_MLP::SIGMOID_SYM);
mlp->setTrainMethod(ml::ANN_MLP::BACKPROP);
mlp->setBackpropMomentumScale(0.1);
mlp->setBackpropWeightScale(0.1);
mlp->setTermCriteria(TermCriteria(CV_TERMCRIT_ITER | CV_TERMCRIT_EPS, 1000, 1e-6));

Mat layers = Mat(3, 1, CV_32SC1);
layers.row(0) = Scalar(2);
layers.row(1) = Scalar(3);
layers.row(2) = Scalar(1);
//layers.row(3) = Scalar(5);

mlp->setLayerSizes(layers);

mlp->train(traindata,ml::ROW_SAMPLE,trainlabel);

Mat responses = Mat(3,1,CV_32FC1);
mlp->predict(testdata,responses);
float result = responses.at<float>(0, 0);

The error message is given below:

Unhandled exception at 0x00007FFE0076855C (opencv_world310d.dll) in fetchvideoapp.exe: 0xC0000005: Access violation reading location 0x000001D3A69DF000.

errormessage.png

Your assistance will be duly appreciated.

Regards.

2016-02-21 06:28:35 -0500 asked a question _CrtlsValidHeapPointer(block) error when using opencv in c++ winforms application

Dear All,

I am trying to use opencv with windows forms application to display an image. I created two extra classes. one as the model and other as the controller class. I imported opencv libraries in the model class, imported the modal class in the controller class and then the controller class in form.h. see code below` Model class

#include "opencv2\core\core.hpp";
#include "opencv2\imgproc\imgproc.hpp";
#include "opencv2\imgcodecs\imgcodecs.hpp"
#include "opencv2\highgui\highgui.hpp"
using namespace cv;
class ReadImage
{
   private:
      cv::String imagepath;
      Mat Image;
   public:
      ReadImage() :imagepath("C:/") {
             ReadImage4rmfile();
      }
      void ReadImage4rmfile() {
        Image = imread(imagepath);
      }
      void setImagepath(cv::String mpath) {
        imagepath = mpath;
      }
      void ShowImage() {
        imshow("ShowImage", Image);
      }
};

Controller class:

#include "ReadImage.hpp"

   class ImageController
   {
        private:
          ReadImage* rimage;
        public:
          ImageController(cv::String mpath) {
             rimage =  new ReadImage();
             rimage->setImagepath(mpath);
          }
          void ImconShowImage() {
             rimage->ShowImage();
          }
          ~ImageController() {
            delete rimage;
         }

 };

forms.h class:

#include "ImageController.hpp"
   private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
    System::String^ temp = textBox1->Text;
    IntPtr pointer_temp = Marshal::StringToHGlobalAnsi(temp);
    const char* input_location = static_cast<const char*>(pointer_temp.ToPointer());

    ImageController Imgcon = ImageController(input_location);
    Imgcon.ImconShowImage();

}

When i run the app i get the following error "Debug failed _CrtlsValidHeapPointer(block)" image description

The funny thing is the opencv settings such as the linker input and the likes was used on console application and it works well and using it winforms am getting this error.

please anyone can help.

2016-01-24 14:09:03 -0500 answered a question Build OpenCV for Python

Dear Peter,

To build opencv 3.1 for python you need python 3.4 installed on computer. Currently i guess you have python 2.7 installed. To use opencv for python 2.7 just copy the pre-built file \build\python\2.7\x64\cv2.pyd from your opencv path to site-packages folder of your python installation folder (windows OS). However to build opencv for python you require python 3.0 and above installed on your system.

2016-01-13 02:05:25 -0500 asked a question How to extract green ground from soccer footage

Hi all,

I am trying to perform player and ball tracking from video footage. Part of my first step is remove ground color green of the field. However having some issues when i display my gray image below its plain black. Below is a sample code:

Mat grayInputimage = Mat(size(inputImage),CV_8UC1);
int blue,green, red;
cvtColor(inputImage,grayInputimage, CV_BGR2GRAY);
for (int i = 0; i < inputImage.rows; i++) {
    for (int j = 0; j < inputImage.cols; j++) {
        blue = inputImage.at<Vec3b>(i, j)[0];
        green = inputImage.at<Vec3b>(i, j)[1];
        red = inputImage.at<Vec3b>(i, j)[2];
        if (green > red && (green > blue && red > blue) ) {
            grayInputimage.at<uchar>(i, j) = 0;
        }
        else {
            grayInputimage.at<uchar>(i, j) = 1;
        }
    }
}

The input image is the frame from the video, while the grayimage should be image without the ground color green of the football pitch. However am not getting this result. I will like if anyone can help.

2016-01-13 01:50:03 -0500 asked a question how to remove green ground from a soccer footage

Hi all,

I am trying to perform player and ball tracking from video footage. How having some issues. Below is a sample code:

Mat grayInputimage = Mat(size(inputImage),CV_8UC1);
int blue,green, red;
cvtColor(inputImage,grayInputimage, CV_BGR2GRAY);
for (int i = 0; i < inputImage.rows; i++) {
    for (int j = 0; j < inputImage.cols; j++) {
        blue = inputImage.at<Vec3b>(i, j)[0];
        green = inputImage.at<Vec3b>(i, j)[1];
        red = inputImage.at<Vec3b>(i, j)[2];
        if (green > red && (green > blue && red > blue) ) {
            grayInputimage.at<uchar>(i, j) = 0;
        }
        else {
            grayInputimage.at<uchar>(i, j) = 1;
        }
    }
}

The input image is the frame from the video, while the grayimage should be image without the ground color green of the football pitch. However am getting this result. I will like if anyone can help.

2015-12-30 02:14:19 -0500 commented question Problem with reading video file opencv 3.1

Hi LBerger,

I found a way around this, it was resolved by adding the path to opencv_ffmpeg310_64.dll to my path variable. All was history.

Thanks for your response.

2015-12-29 14:23:03 -0500 commented question Problem with reading video file opencv 3.1

Hi LBerger,

The example in starter_video.cpp still fails read from the video file and then opens my webcam as seen from the code snippet below:

VideoCapture capture(arg); //try to open string, this will attempt to open it as a video file or image sequence
if (!capture.isOpened()) //if this fails, try to open as a video camera, through the use of an integer param
    capture.open(atoi(arg.c_str()));er code here
2015-12-29 13:29:51 -0500 received badge  Scholar (source)
2015-12-29 13:28:55 -0500 commented question Problem with reading video file opencv 3.1

Hi LBerger, tried that still did not work.

2015-12-29 11:32:06 -0500 asked a question Problem with reading video file opencv 3.1

Hi All,

I just recently installed opencv3.1 and i wanted to read a video file. Everything seem fine to as i have used code before. Please anyone look at this:

VideoCapture capture;

while (1) {
    capture.open("C:/Users/hp/Documents/motionTrackingTutorial/bouncingBall.avi");

    if (!capture.isOpened()) {
        cout << "ERROR ACQUIRING VIDEO FEED\n";
        getchar();
        return -1;
    }

          // ...............other code are implemented here
    }

The video file is not read as "ERROR ACQUIRING VIDEO FEED" is been displayed. Please can anyone help.

2015-12-29 11:10:22 -0500 commented answer Problem building opencv 3.1 with cuda 7.5

Hi, john I have solved the problem, i just had the compiler type to "14 vs2015 win 64" and it worked like a charm. As for your question VS2015 and cuda 7.5, yes all you need to do is install cuda toolkit 7.5 and install install Nsight studio 5.0 and you good to go. see the site below: [https://developer.nvidia.com/gamework...]

2015-12-28 19:57:48 -0500 asked a question Problem building opencv 3.1 with cuda 7.5

Dear All,

I currently was to build the new version of opencv with cuda 7.5. I have visual studio 2015 installed and since cuda toolkit 7.5 does not support VS2015 i had to install nsight studio 5.0 to support VS2015. I started building with cmake and upon configuring i get the following error CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: CUDA_cufft_LIBRARY (ADVANCED) linked by target "opencv_cudev" in directory C:/opencv/sources/modules/cudev linked by target "opencv_test_cudev" in directory C:/opencv/sources/modules/cudev/test linked by target "opencv_perf_core" in directory C:/opencv/sources/modules/core linked by target "opencv_core" in directory C:/opencv/sources/modules/core linked by target "opencv_test_core" in directory C:/opencv/sources/modules/core linked by target "opencv_perf_cudaarithm" in directory C:/opencv/sources/modules/cudaarithm linked by target "opencv_cudaarithm" in directory C:/opencv/sources/modules/cudaarithm linked by target "opencv_cudaarithm" in directory C:/opencv/sources/modules/cudaarithm linked by target "opencv_test_cudaarithm" in directory C:/opencv/sources/modules/cudaarithm linked by target "opencv_flann" in directory C:/opencv/sources/modules/flann linked by target "opencv_test_flann" in directory C:/opencv/sources/modules/flann linked by target "opencv_perf_imgproc" in directory C:/opencv/sources/modules/imgproc linked by target "opencv_test_imgproc" in directory C:/opencv/sources/modules/imgproc linked by target "opencv_imgproc" in directory C:/opencv/sources/modules/imgproc linked by target "opencv_ml" in directory C:/opencv/sources/modules/ml linked by target "opencv_test_ml" in directory C:/opencv/sources/modules/ml linked by target "opencv_perf_video" in directory C:/opencv/sources/modules/video linked by target "opencv_video" in directory C:/opencv/sources/modules/video linked by target "opencv_test_video" in directory C:/opencv/sources/modules/video linked by target "opencv_perf_cudabgsegm" in directory C:/opencv/sources/modules/cudabgsegm linked by target "opencv_cudabgsegm" in directory C:/opencv/sources/modules/cudabgsegm linked by target "opencv_test_cudabgsegm" in directory C:/opencv/sources/modules/cudabgsegm linked by target "opencv_test_cudafilters" in directory C:/opencv/sources/modules/cudafilters linked by target "opencv_perf_cudafilters" in directory C:/opencv/sources/modules/cudafilters linked by target "opencv_cudafilters" in directory C:/opencv/sources/modules/cudafilters linked by target "opencv_cudaimgproc" in directory C:/opencv/sources/modules/cudaimgproc linked by target "opencv_test_cudaimgproc" in directory C:/opencv/sources/modules/cudaimgproc linked by target "opencv_perf_cudaimgproc" in directory C:/opencv/sources/modules/cudaimgproc linked by target "opencv_test_cudawarping" in directory C:/opencv/sources/modules/cudawarping linked by target "opencv_perf_cudawarping" in directory C:/opencv/sources/modules/cudawarping linked by target "opencv_cudawarping" in directory C:/opencv/sources/modules/cudawarping linked by target "opencv_test_imgcodecs" in directory C:/opencv/sources/modules/imgcodecs linked by target "opencv_imgcodecs" in directory C:/opencv/sources/modules/imgcodecs linked by target "opencv_perf_imgcodecs" in directory C:/opencv/sources/modules/imgcodecs linked by target "opencv_photo" in directory C:/opencv/sources/modules/photo linked by target "opencv_test_photo" in directory C:/opencv/sources/modules/photo linked by target "opencv_perf_photo" in directory C:/opencv/sources/modules/photo linked by ... (more)

2015-12-28 12:12:49 -0500 asked a question object tracking in video sequence

Hi team,

I want suggestions to object tracking algorithms for a video using opencv. Your help will be duly appreciated.

Regards.

2015-10-14 00:01:06 -0500 asked a question How start using cuda with opencv 3.0

Hello guys,

i came across cuda and learnt that you could use for hard acceleration in opencv. Currently my computer is NVIDIA supported and i have installed cuda toolkit. How do use this with opencv, is there any good tutorial out there that can help? Please your help will duly appreciated. Regards.

2015-09-27 12:32:42 -0500 asked a question Using GPU with OpenCV 3.0

Hi All,

I noticed that gpu module for opencv 3.0rc1 is no longer available as compared to the 2.4.x versions. How can i use GPU with opencv 3.0 current releases. Your help will be duly appreciated.

Regards.

2015-09-06 06:02:04 -0500 commented question Relevance Vector Machines

Thanks berak. You are the best.

2015-09-05 16:29:19 -0500 answered a question How to obtain all matching scores in LBPHFaceRecognizer

Dear MikeMartin,

Its easy copy out the LBPH code from opencv_contrib module and place it in a new file and good to go. find the attached my file lBP. Provide your email to send you the modified code.

2015-09-05 15:15:17 -0500 asked a question Relevance Vector Machines

Hi guys,

Can anyone tell how to go about the implementation of Relevance Vector Machine in OpenCV.

Your help will be duly appreciated.

2015-08-25 17:21:15 -0500 received badge  Self-Learner (source)
2015-08-25 17:21:08 -0500 received badge  Student (source)
2015-08-24 07:41:42 -0500 commented question image step not continuous after dividing an image

Its working now. i had to clone the image before reshaping. @berak the x and y values are the different blocks am dividing the cols and rows of the image into. Thanks sturkmen and berak.

2015-08-24 06:31:52 -0500 asked a question image step not continuous after dividing an image

Hi everyone,

I am try to divide an image into blocks in opencv and i get the "Error image step is not continuous". Pls here is my code need your help.

vector<Mat> ilmage;
    int N = (images[0].cols * images[0].rows) / (x*y);
    Mat t;

    int m = images[0].rows / x;
    int n = images[0].cols / y;
    int i2, i3, i4, i5;
    Size smallsize(n, m);

    for (int i = 0; i < images.size(); i++){
        for (int j = 0; j < images[i].rows; j += smallsize.height){
            for (int k = 0; k < images[i].cols; k += smallsize.width ){
                //i2 = k*n, i3 = n, i4 = j*m; i5 = m;
                t = images[i](Rect(k, j, smallsize.width,smallsize.height));
                ilmage.push_back(transpose(t.reshape(0, N)));
            }
        }
        pImage.push_back(ilmage);
        ilmage.clear();
    }

Regards.

2015-08-24 00:37:34 -0500 asked a question How to perform mean variance normalization on face image

Hi all,

How can i perform mean variance normalization on a given face image in order to reduce illumination effects in opencv.

Your answers or links will be duly appreciated.

Regards.

2015-07-19 12:47:41 -0500 commented question How to calculate FAR and FRR for a biometric system

Thanks stevens.

2015-07-19 11:37:52 -0500 asked a question How to calculate FAR and FRR for a biometric system

Hello everyone,

I want to be sure i have clear understanding on this concept. I know to calculate FAR (False Acceptance Rate) and FRR (False Rejection Rate) i have to vary the system at different thresholds to different genuine and impostors. For a given threshold if the FRR is the number of classes in the training set whose distance with the same class test sample is greater than the threshold. FAR is the number of classes in the training set whose distance with different class test sample is greater than the threshold.

Please will need confirmation any who understands this concept. I want know if my understanding right before writing codes.

Thanks in advance.

2015-07-16 12:13:54 -0500 answered a question How to read a Matrix from a child node with FileStorage API

Hello everyone.

Here is what i did to resolve this issue.

void readfeaturesFileNodeList(const FileNode& fn, vector<Mat>& result, int i){
    string element1;
    Mat feat;
    for (FileNodeIterator current = fn.begin(); current != fn.end();current++){
        element1 = "f" + to_string(i);
        FileNode rt = *current;
        rt[element1]>> feat;
        result.push_back(feat);
    }
}

and the second function is given below.

void ReadGlobalFeatures(string filename,vector<Mat>& Fvector){
    FileStorage fs(filename, FileStorage::READ);
    Mat feat;
    vector<Mat> vfeat;
    string element;
    string element1;
    FileNode k = fs.root();

    for (int i = 0; i <TrainLabels.size(); i++){
        //element1 = "f" + to_string(i);
        FileNode tempID = k;
        readfeaturesFileNodeList(tempID, vfeat,i);
    }
    Fvector = vfeat;
    fs.release();
}

Thanks berak and all who contributed to this i am really grateful. This is truly the best opencv forum and i have learnt from all you.

2015-07-14 15:40:57 -0500 commented answer How to read a Matrix from a child node with FileStorage API

Dear berak,

Thanks for answer. done exactly this but its reading wrong values. The values am getting its wat in xml file

2015-07-14 12:12:50 -0500 commented question How to read a Matrix from a child node with FileStorage API

@berak, yes

2015-07-12 12:15:27 -0500 commented question How to read a Matrix from a child node with FileStorage API

Tried using FileNodeIterator but only returns one Matrix. Please need help on this.

2015-07-12 10:48:00 -0500 asked a question How to read a Matrix from a child node with FileStorage API

Hello guys,

I am having a little issue here. I saved a couple of mat as child nodes in xml using the Filestorage API in opencv. However when i try to read them back the filestorage API reads the same values which are wrong for all the Matrices in the xml file. I don't know where am getting it wrong. please help.

Here is my code for writing and reading.

FileStorage file(filename, FileStorage::WRITE);
file << "Features" << "{";
for (int i = 0; i < TrainFeatureVector.size(); i++){
  string element1 = "f" + to_string(i);
  file << element1 << TrainFeatureVector[i];
}
file << "}"

FileStorage fs(filename, FileStorage::READ);
Mat feat;
string element;
string element1;
FileNode k = fs["Features"];
for (int i = 0; i < k.size(); i++){
 element1 = "f" + to_string(i);
 k[element1] >> feat;
 Fvector.push_back(feat);}

Here is my xml file C:\fakepath\sxml.png

2015-07-09 12:47:06 -0500 commented question How vector from an xml file with FileStorage Opencv API

Sorry guys my error. its in the condition of the for loop.

2015-07-09 12:37:20 -0500 asked a question How vector from an xml file with FileStorage Opencv API

Hello everyone,

I am having issues read vector of matching scores from an xml file using the filestorage API in opencv c++.

When the code starts running it never stops. Just keeps ongoing. I suspect there is something wrong with an iteration somewhere but i dont know where. Here is my code for reading the scores:

void readFileNodeList(const FileNode& fn, vector<double>& result)
{
    if (fn.type() == FileNode::SEQ) {
        for (FileNodeIterator it = fn.begin(); it != fn.end();) {
            double item;
            it >> item;
            result.push_back(item);
        }
    }
}
/*Reads a vector of Matching scores from the xml file*/
void ReadScores(string filename,vector<vector<double>> Mvector){
    FileStorage fs(filename, FileStorage::READ);
    string element;
    vector<double> value;
    FileNode n = fs["score"];
    for (int i = 0; TestLabels.size(); i++){
        element = "s" + to_string(i);
        FileNode tempID = n[element];
        readFileNodeList(tempID, value);
        Mvector.push_back(value);
        value.clear();
    }
    fs.release();
}

Here is my xml file:

C:\fakepath\yxml.png

Please help.....