DetectionMetrics
DetectionMetrics copied to clipboard
Add support for Recorder Reader
See this build log. You will see issues similar to:
/Users/travis/build/JdeRobot/dl-DetectionSuite/DeepLearningSuite/DeepLearningSuiteLib/DatasetConverters/liveReaders/GenericLiveReader.cpp:129:31: warning: adding 'LIVEREADER_IMPLEMENTATIONS' to a string does not append to the string [-Wstring-plus-int]
LOG(WARNING)<<imp + " is not a valid reader implementation";
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/travis/build/JdeRobot/dl-DetectionSuite/DeepLearningSuite/DeepLearningSuiteLib/DatasetConverters/liveReaders/GenericLiveReader.cpp:129:31: note: use array indexing to silence this warning
This error is occurring because a variable of type enum is being appended to a string.
Okay , will start working on it
i think we shall replace imp with "recorder" as this is the remaining value of enum imp with value equals to 0
Hi, @teamleader6 your solution will work but is a temporary fix, what if we have multiple values in enum, which are invalid.
I just had a look at the code of RecorderReader.h which isn't currently supported. It wasn't written by me, but after reading it I think we can support it. It is a simple code which reads some images from a path in rgb and depth format.
Using dummy rgb and depth images, see if RecorderReader works. I am changing this issue to add support for already written Recorder Reader if possible. This will also help you to get familiar with the codebase of DetectionSuite.
Feel free to comment below if you face any issues or have any questions.
RecorderReader.cpp is present here.
@vinay0410 i will work on it
RecorderReader.h:9:10: fatal error: Common/Sample.h: No such file or directory i searched but i didn't found sample.h i don't know is this related to version of c++ or not
It's present here, https://github.com/JdeRobot/dl-DetectionSuite/blob/master/DeepLearningSuite/DeepLearningSuiteLib/Common/Sample.h
RecorderReader.h isn't importing it correctly. Although you need not include it, since it's already present in #include "DatasetConverters/readers/DatasetReader.h" which is included in RecorderReader.h
You may take hint from this file on how it's done https://github.com/JdeRobot/dl-DetectionSuite/blob/master/DeepLearningSuite/DeepLearningSuiteLib/DatasetConverters/liveReaders/CameraReader.h
test.cpp to support RecorderReader
#include pkg-config --cflags --libs opencv
i get 2 errors after tones of errors at beginning
/tmp/cc9i5xOM.o: In function main': test.cpp:(.text+0xad): undefined reference to RecorderReader::RecorderReader(std::__cxx11::basic_string<char, std::char_traits
after modifying those files modifying include to the right paths ,..etc
RecorderReader.cpp // // Created by frivas on 16/11/16. //
#include "RecorderReader.h" #include <boost/program_options.hpp> #include <boost/filesystem.hpp> #include <boost/algorithm/string/predicate.hpp> #include "../../Utils/PathHelper.h" #include <boost/algorithm/string/erase.hpp> #include <glog/logging.h> #include "opencv2/opencv.hpp"
RecorderReader::RecorderReader(const std::string &colorImagesPath, const std::string &depthImagesPath):DatasetReader(true), colorPath(colorImagesPath), depthPath(depthImagesPath) { currentIndex=0; syncedData=false; getImagesByIndexes(depthPath,depthIndexes); getImagesByIndexes(colorPath,colorIndexes); }
RecorderReader::RecorderReader(const std::string &dataPath):DatasetReader(true), colorPath(dataPath), depthPath(dataPath) { currentIndex=0; syncedData=true; getImagesByIndexes(dataPath,depthIndexes,"-depth"); getImagesByIndexes(dataPath,colorIndexes,"-rgb"); }
void RecorderReader::getImagesByIndexes(const std::string& path, std::vector
boost::filesystem::directory_iterator end_iter;
for (boost::filesystem::directory_iterator dir_itr(path);
dir_itr != end_iter; dir_itr++) {
if (boost::filesystem::is_regular_file(*dir_itr) && dir_itr->path().extension() == ".png") {
std::string onlyIndexFilename;
if (not sufix.empty()) {
std::string filename=dir_itr->path().stem().string();
if ( ! boost::algorithm::ends_with(filename, sufix)){
continue;
}
onlyIndexFilename=dir_itr->path().filename().stem().string();
boost::erase_all(onlyIndexFilename,sufix);
}
else{
onlyIndexFilename=dir_itr->path().filename().stem().string();
}
LOG(INFO) << dir_itr->path().string() << std::endl;
LOG(INFO) << onlyIndexFilename << std::endl;
indexes.push_back(std::stoi(onlyIndexFilename));
}
}
}
if (indexes.empty()){
DLOG(WARNING) << "No images found in input sample path";
}
std::sort(indexes.begin(), indexes.end());
}
std::string RecorderReader::getPathByIndex(const std::string& path, int id,std::string sufix){ std::stringstream ss; ss << id << sufix << ".png"; std::string pathCompleted = PathHelper::concatPaths(path, ss.str()); return pathCompleted; }
int RecorderReader::closest(std::vector
return *it;
}
bool RecorderReader::getNextSample(Sample &sample) { if (this->currentIndex < this->depthIndexes.size()){ int indexValue = this->depthIndexes[currentIndex]; LOG(INFO)<<"Time stamp: " + std::to_string(indexValue);
cv::Mat colorImage= cv::imread(getPathByIndex(this->colorPath,closest(colorIndexes,indexValue),this->syncedData?"-rgb":""));
// if (!this->syncedData) cv::cvtColor(colorImage,colorImage,cv::COLOR_RGB2BGR);
sample.setColorImage(colorImage);
sample.setDepthImage(getPathByIndex(this->depthPath,indexValue,this->syncedData?"-depth":""));
this->currentIndex++;
return true;
}
return false;
}
int RecorderReader::getNumSamples() { return (int)this->depthIndexes.size(); }
RecorderReader::~RecorderReader(){
} RecorderReader.h // Created by frivas on 16/11/16. //
#ifndef SAMPLERGENERATOR_RECORDERCONVERTER_H #define SAMPLERGENERATOR_RECORDERCONVERTER_H
#include
class RecorderReader: public DatasetReader { public: RecorderReader(const std::string& colorImagesPath, const std::string& depthImagesPath); explicit RecorderReader(const std::string& dataPath); bool getNextSample(Sample &sample) override; int getNumSamples(); ~RecorderReader(); // virtual bool getNextSample(Sample &sample);
private:
const std::string& depthPath;
const std::string& colorPath;
bool syncedData;
int currentIndex;
std::vector
void getImagesByIndexes(const std::string& path, std::vector<int>& indexes, std::string sufix="");
std::string getPathByIndex(const std::string& path,int id, std::string sufix="");
int closest(std::vector<int> const& vec, int value);
};
typedef boost::shared_ptr<RecorderReader> RecorderReaderPtr;
#endif //SAMPLERGENERATOR_RECORDERCONVERTER_H
DatasetReader.h // // Created by frivas on 22/01/17. //
#ifndef SAMPLERGENERATOR_DATASETREADER_H #define SAMPLERGENERATOR_DATASETREADER_H
#include
#include "../../Common/Sample.h" #include <boost/shared_ptr.hpp> #include "../../Common/EvalMatrix.h" #include <glog/logging.h>
class DatasetReader { public: DatasetReader(const bool imagesRequired); virtual bool getNextSample(Sample &sample); virtual bool getNextSamples(std::vector<Sample> &samples, int size ); void filterSamplesByID(std::vectorstd::string filteredIDS); void overWriteClasses(const std::string& from, const std::string& to); int getNumberOfElements(); void resetReaderCounter(); void decrementReaderCounter(const int decrement_by = 1); void incrementReaderCounter(const int increment_by = 1); bool getSampleBySampleID(Sample** sample, const std::string& sampleID); bool getSampleBySampleID(Sample** sample, const long long int sampleID); void printDatasetStats(); virtual bool appendDataset(const std::string& datasetPath, const std::string& datasetPrefix=""); void addSample(Sample sample); std::string getClassNamesFile(); virtual ~DatasetReader();
protected: std::vector<Sample> samples; //std::string datasetPath; int readerCounter; std::string classNamesFile; std::vectorstd::string classNames; bool imagesRequired; unsigned int skip_count = 10; //max Number of annotations that can be skipped if Corresponding images weren't found };
typedef boost::shared_ptr<DatasetReader> DatasetReaderPtr;
#endif //SAMPLERGENERATOR_DATASETREADER_H
You are supposed to integrate this with DetectionSuite and then build using the steps mentioned
i solved another problem and the problem was in building and i builded well after modifications i did like you said i want ask how can i test RecorderReader now or just you want fixing errors and make pull request with final modifications in files
It is a simple code which reads some images from a path in rgb and depth format.
Using dummy rgb and depth images, see if RecorderReader works.