load csv file and display image [closed]

asked 2018-02-27 05:53:44 -0600

shive gravatar image

updated 2018-02-27 05:54:17 -0600

hi... i am trying to load a csv file and display the images.. but it showing blank image... someone plz help me wit this... thanks in advance.

      #include "opencv2/core.hpp"
      #include "opencv2/highgui.hpp"
      #include "opencv2/face.hpp"
      #include "opencv2/ml.hpp"
      #include "opencv2/imgproc.hpp"
      #include <iostream>
     #include <fstream>
     #include <sstream>
     using namespace std;
     using namespace cv;
     using namespace cv::face;

      int main()
      {
     Mat img;
   cv::Ptr<cv::ml::TrainData> raw_data = cv::ml::TrainData::loadFromCSV("///home/veena/Desktop/1_seq40.csv", 0, -2, 0);
   Mat tdata = raw_data->getSamples();
   tdata.convertTo(img, CV_8UC3);
   img.convertTo(img, CV_8UC3);
  resize(img, img, Size(300,300));
  namedWindow("img");
  imshow("img", img);
  waitKey(0);
  return 0;
 }
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-08-30 03:13:26.304280

Comments

what on earth might be in the csv file ?

berak gravatar imageberak ( 2018-02-27 05:56:15 -0600 )edit

and there's no place like ///home

berak gravatar imageberak ( 2018-02-27 09:29:05 -0600 )edit

i have created a csv file with image path..

shive gravatar imageshive ( 2018-02-28 04:34:47 -0600 )edit

Actually it should display the image which is in the path of csv file, but it showing an blank image.

shive gravatar imageshive ( 2018-02-28 04:57:12 -0600 )edit

then, you cannot use :ml::TrainData, it expects a label and actual pixels in the csv, not a filename

berak gravatar imageberak ( 2018-02-28 05:01:26 -0600 )edit