-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Hi I am trying to execute a part of the code to understand the output at each stage I was wondering if u could tell me how to pass the image root path to execute the program training.cpp code. I want to know the type of input and to be passed i am trying to test.:
include <stdio.h>
include
include
include
include <boost/filesystem.hpp>
include
include <opencv2/opencv.hpp>
include "opencv2/imgproc/imgproc.hpp"
include
include <stdlib.h>
include <opencv2/core/core.hpp>
include <opencv2/highgui/highgui.hpp>
include <opencv2/nonfree/features2d.hpp>
include <opencv2/ml/ml.hpp>
using namespace std;
using namespace boost::filesystem;
using namespace cv;
int read_images(char *root, vector &images, vector &labels, vector &names)
{
std::cout<<"Reaced the code"<<std::endl;
path p(root);
cout<<"PAth :"<<p<<std::endl;
if ( !exists( p ) )
{
std::cout<<root<<" Not Exist"<<std::endl;return -1;
}
if ( !is_directory( p ) )
{
std::cout<<root<<" Directory Not Exist"<<std::endl;return -1;
}
vector<path> vec;
copy(directory_iterator(p), directory_iterator(), back_inserter(vec));
vector<path>::const_iterator it;
int num = 0;
int count = 0;
int stringlength, found_char, namelength;
string str;
string picname;
string slash = "/";
for (it = vec.begin(); it != vec.end() ; ++it)
{
//string test= string(it);
std::cout<<"Reaced :"<<std::endl;
if ( !is_directory(*it))
{
std::cout<<"Still Continuing"<<!is_directory(*it)<<std::endl;
continue;
}
// Get the name of this image within the filepath
cout << (*it).string() << endl;
str = (*it).string();
stringlength = str.size();
found_char = str.rfind(slash);
namelength = stringlength-found_char;
picname = str.substr(found_char+1,namelength);
vector<path> vec2;
copy(directory_iterator(*it), directory_iterator(), back_inserter(vec2));
vector<path>::const_iterator it2;
for (it2 = vec2.begin(); it2 != vec2.end(); ++it2)
{
//if (is_hidden(*it2))
// continue;
// This fuction reads in the color image
Mat im = imread( (*it2).string(), CV_LOAD_IMAGE_GRAYSCALE);
std::cout<<"im :"<<im<<std::endl;
std::cout<<"labels:"<<num<<std::endl;
std::cout<<"names :"<<picname<<std::endl;
// This iterates through the values that we have that holds the vectors
images.push_back(im);
labels.push_back(num);
names.push_back(picname);
count++;
std::cout<<"Count value :"<<count<<std::endl;
std::cout<<"Num Value :"<<num<<std::endl;
}
num++;
// TODO: Remove this to use more than 3 classes.
if (num > 100)
break;
}
return num;
}
int main(int argc, char *argv[])
{
std::cout<<"Entered Main"<<std::endl;
char *image_root = argv[1];//"C:\Users\Reeba\Desktop\testdata\ukbench00000.jpg";
char *model_output = NULL;
char *vocab_output = NULL;
/*
if (argc == 4) {
model_output = argv[2];
vocab_output = argv[3];
}
*/
vector<Mat> images;
vector<int> labels;
vector<string> names;
int num = read_images(image_root, images, labels, names);
std::cout<<" Num from Main :"<<num;
}
I modified the code to see the output. I try to give the input as
C:\Users\Reeba\Documents\Visual Studio 2010\Projects\TestRun\Debug>TestRun.exe C
:\Users\Reeba\Desktop\test
it has 4 images and a textfile with the the data
C:/Users/Reeba/Desktop/testdata/ukbench00000
C:/Users/Reeba/Desktop/testdata/ukbench00001
where ukbench00000 and ukbench00001 are .jpg images
I would really like some help.