4 Replies - 255 Views - Last Post: 28 February 2018 - 06:35 AM Rate Topic: -----

#1 shive   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 03-December 17

load csv file and display image

Posted 27 February 2018 - 05:01 AM

hi... i am trying to load a csv file and display the images.. but it showing blank image... someone please 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;
      }


This post has been edited by no2pencil: 27 February 2018 - 06:17 AM
Reason for edit:: Added Code Tags


Is This A Good Question/Topic? 0
  • +

Replies To: load csv file and display image

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6643
  • View blog
  • Posts: 30,932
  • Joined: 10-May 07

Re: load csv file and display image

Posted 27 February 2018 - 06:17 AM

** Moved to C/C++ **
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6217
  • View blog
  • Posts: 21,468
  • Joined: 05-May 12

Re: load csv file and display image

Posted 27 February 2018 - 06:28 AM

I don't use OpenCV. I assume that the C++ wrappers for it throw exceptions (instead of the C-style returning error codes). Are you getting any exceptions? If my assumption is wrong regarding exceptions, are you checking for error codes?
Was This Post Helpful? 0
  • +
  • -

#4 shive   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 03-December 17

Re: load csv file and display image

Posted 28 February 2018 - 03:55 AM

its not showing any error ..my program executing without errors, it should display an image which is in the csv file path but it showing a blank image.. i am unable to understand what's the prob is?

This post has been edited by Skydiver: 28 February 2018 - 06:31 AM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is online

  • Code herder
  • member icon

Reputation: 6217
  • View blog
  • Posts: 21,468
  • Joined: 05-May 12

Re: load csv file and display image

Posted 28 February 2018 - 06:35 AM

There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area.

I would start by stepping through the code and inspecting values, and adding some debugging code. For example, after the data is put into tdata, I would try to see how many elements are actually in it by checking the return value of Mat::total(). If it is non-zero, then start iterating over the rows and columns to make sure that some values are non-zero.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1