Skip to content
Snippets Groups Projects
Commit b35d87f9 authored by am0ebe's avatar am0ebe
Browse files

.

parent ed6b10cc
Branches
No related tags found
No related merge requests found
...@@ -36,21 +36,21 @@ int g_badSignalFlagAbort = 0; ...@@ -36,21 +36,21 @@ int g_badSignalFlagAbort = 0;
void my_handler(int signum); void my_handler(int signum);
char* getCmdOption(char ** begin, char ** end, const std::string & option); char* getCmdOption(char ** begin, char ** end, const string & option);
bool cmdOptionExists(char** begin, char** end, const std::string& option); bool cmdOptionExists(char** begin, char** end, const string& option);
std::vector<char> copyDataInBuffer(struct archive *aw); vector<char> copyDataInBuffer(struct archive *aw);
//! we convert our actual jpg file number to framenumber //! we convert our actual jpg file number to framenumber
int toFrameNumber(std::string filename); int toFrameNumber(string filename);
int main(int argc, char * argv[]) int main(int argc, char * argv[])
{ {
signal(SIGUSR1, my_handler); signal(SIGUSR1, my_handler);
std::cout << "using processcenter " << PROCESS_CENTER_VERSION_MAJOR <<"."<< PROCESS_CENTER_VERSION_MINOR<<"."<<PROCESS_CENTER_VERSION_MINOR_FIXES<< endl; cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << endl;
std::cout << "Using OpenCV " << CV_MAJOR_VERSION << "." << CV_MINOR_VERSION << "." << CV_SUBMINOR_VERSION << std::endl; cout << "Using processcenter " << PROCESS_CENTER_VERSION_MAJOR << "." << PROCESS_CENTER_VERSION_MINOR<< "." <<PROCESS_CENTER_VERSION_MINOR_FIXES<< endl << endl;
//!** parse programm input****************/ //!** parse programm input****************/
...@@ -61,8 +61,8 @@ int main(int argc, char * argv[]) ...@@ -61,8 +61,8 @@ int main(int argc, char * argv[])
|| !cmdOptionExists(argv, argv+argc, "-o") || !cmdOptionExists(argv, argv+argc, "-o")
|| !cmdOptionExists(argv, argv+argc, "-p")) || !cmdOptionExists(argv, argv+argc, "-p"))
{ {
cout <<" Usage:" << endl; cout << " Usage:" << endl;
cout << " " << argv[0] << " -i in.tar -a amount -c center.xml -o outPath -p camparameterFile.xml"<< endl << endl; cout << " " << argv[0] << " -i in.tar -a amount -c center.xml -o outPath -p camparameterFile.xml" << endl << endl;
cout << " Options:" << endl; cout << " Options:" << endl;
cout << " i - input tarfile/dir containing tars ?" << endl; cout << " i - input tarfile/dir containing tars ?" << endl;
cout << " a - amount of files/frames ?" << endl; cout << " a - amount of files/frames ?" << endl;
...@@ -74,7 +74,7 @@ int main(int argc, char * argv[]) ...@@ -74,7 +74,7 @@ int main(int argc, char * argv[])
} }
char *testFile = getCmdOption(argv, argv + argc, "-i"); char *testFile = getCmdOption(argv, argv + argc, "-i");
std::string inputFile("."); string inputFile(".");
if (testFile) if (testFile)
{ {
//test dir exists //test dir exists
...@@ -92,7 +92,7 @@ int main(int argc, char * argv[]) ...@@ -92,7 +92,7 @@ int main(int argc, char * argv[])
char *centerFile = getCmdOption(argv, argv + argc, "-c"); char *centerFile = getCmdOption(argv, argv + argc, "-c");
std::string centerFileString("."); string centerFileString(".");
if (centerFile) if (centerFile)
{ {
//test dir exists //test dir exists
...@@ -100,7 +100,7 @@ int main(int argc, char * argv[]) ...@@ -100,7 +100,7 @@ int main(int argc, char * argv[])
} }
char *testOutputDir = getCmdOption(argv, argv + argc, "-o"); char *testOutputDir = getCmdOption(argv, argv + argc, "-o");
std::string outputDir("."); string outputDir(".");
if (testOutputDir) if (testOutputDir)
{ {
//test dir exists //test dir exists
...@@ -108,7 +108,7 @@ int main(int argc, char * argv[]) ...@@ -108,7 +108,7 @@ int main(int argc, char * argv[])
} }
char *camerFile = getCmdOption(argv, argv + argc, "-p"); char *camerFile = getCmdOption(argv, argv + argc, "-p");
std::string cameraParameterFile("."); string cameraParameterFile(".");
if (camerFile) if (camerFile)
{ {
//test dir exists //test dir exists
...@@ -116,7 +116,7 @@ int main(int argc, char * argv[]) ...@@ -116,7 +116,7 @@ int main(int argc, char * argv[])
} }
cout <<"args: -i "<<inputFile<<" -a "<<amountFiles << " -c" << centerFileString<<" -o " << outputDir <<" -p " << cameraParameterFile << endl; cout << "args: -i " <<inputFile<< " -a " <<amountFiles << " -c" << centerFileString<< " -o " << outputDir << " -p " << cameraParameterFile << endl;
//!**** end parse input***********/ //!**** end parse input***********/
//libarchive things //libarchive things
...@@ -141,10 +141,12 @@ int main(int argc, char * argv[]) ...@@ -141,10 +141,12 @@ int main(int argc, char * argv[])
//and open the handler //and open the handler
if ((r = archive_read_open_filename(archive, filename, 10240))) if ((r = archive_read_open_filename(archive, filename, 10240)))
{ {
cerr<<"archive_read_open_filename: error: "<< archive_error_string(archive) <<" will abort"<< endl; cerr<< "archive_read_open_filename: error: " << archive_error_string(archive) << " will abort" << endl;
exit(1); exit(1);
} }
/* #### Background Subtraction Methods ##### /* #### Background Subtraction Methods #####
Codebook is new! Codebook is new!
...@@ -180,25 +182,25 @@ int main(int argc, char * argv[]) ...@@ -180,25 +182,25 @@ int main(int argc, char * argv[])
int circleCenterX = 880; int circleCenterX = 880;
int circleCenterY = 750; int circleCenterY = 750;
int circleRadius = 700; int circleRadius = 700;
cv::String configFileNameCenter(centerFileString); cv::String configFileNameCenter(centerFileString);
//read the config //read the config
cout << "parameter of centerConfigFile.xml" << endl; cout << "parameter of centerConfigFile.xml" << endl;
FileStorage fsCen; FileStorage fsCen;
fsCen.open(configFileNameCenter, FileStorage::READ); fsCen.open(configFileNameCenter, FileStorage::READ);
if (!fsCen.isOpened()) if (!fsCen.isOpened())
{ {
cout << "error during open " << centerFileString << " will abort" << endl; cout << "error during open " << centerFileString << " will abort" << endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
circleCenterX = (int) fsCen["circleCenterX"]; circleCenterX = (int) fsCen["circleCenterX"];
cout <<"circleCenterX: "<< circleCenterX << endl; cout << "circleCenterX: " << circleCenterX << endl;
circleCenterY = (int) fsCen["circleCenterY"]; circleCenterY = (int) fsCen["circleCenterY"];
cout <<"circleCenterY: "<< circleCenterY << endl; cout << "circleCenterY: " << circleCenterY << endl;
circleRadius = (int) fsCen["circleRadius"]; circleRadius = (int) fsCen["circleRadius"];
cout <<"circleRadius: "<< circleRadius << endl; cout << "circleRadius: " << circleRadius << endl;
fsCen.release(); fsCen.release();
...@@ -206,33 +208,33 @@ int main(int argc, char * argv[]) ...@@ -206,33 +208,33 @@ int main(int argc, char * argv[])
cv::String camParam (cameraParameterFile); cv::String camParam (cameraParameterFile);
Mat intrinsicsCameraMatrix, distortionCoeff; Mat intrinsicsCameraMatrix, distortionCoeff;
{ {
cout << "read cam parameter of: "<< cameraParameterFile << endl; cout << "read cam parameter of: " << cameraParameterFile << endl;
FileStorage fs; FileStorage fs;
fs.open(camParam, FileStorage::READ); fs.open(camParam, FileStorage::READ);
if (!fs.isOpened()) if (!fs.isOpened())
{ {
cerr << "error during open " << cameraParameterFile << " will abort" << endl; cerr << "error during open " << cameraParameterFile << " will abort" << endl;
return -1; return -1;
} }
// fs["camera_matrix"] >> intrinsicsCameraMatrix; fs["camera_matrix"] >> intrinsicsCameraMatrix;
// fs["distortion_coefficients"] >> distortionCoeff; fs["distortion_coefficients"] >> distortionCoeff;
intrinsicsCameraMatrix = (int) fs["camera_matrix"]; // intrinsicsCameraMatrix = (int) fs["camera_matrix"];
// intrinsicsCameraMatrix = fs["camera_matrix"].mat(); // intrinsicsCameraMatrix = fs["camera_matrix"].mat();
cout << "camera_matrix = "<< intrinsicsCameraMatrix << endl; cout << "camera_matrix = " << intrinsicsCameraMatrix << endl;
distortionCoeff = (int) fs["distortion_coefficients"]; // distortionCoeff = (int) fs["distortion_coefficients"];
// distortionCoeff = fs["distortion_coefficients"].mat(); // distortionCoeff = fs["distortion_coefficients"].mat();
cout << "distortion_coefficients = " << distortionCoeff << endl; cout << "distortion_coefficients = " << distortionCoeff << endl;
} }
cout.flush(); cout.flush();
cout <<"a) we process all frames "<<endl; cout << "a) we process all frames " << endl;
int everyPic= 60*5; int everyPic= 60*5;
//std::string fileName; //string fileName;
int frameCounter=0; int frameCounter=0;
int myFileTarWriterHeaderCounter = 0; int myFileTarWriterHeaderCounter = 0;
int frameCounterOld = -1; int frameCounterOld = -1;
...@@ -240,13 +242,15 @@ int main(int argc, char * argv[]) ...@@ -240,13 +242,15 @@ int main(int argc, char * argv[])
vector<string> myFileListNoContour; //list for no contours found; vector<string> myFileListNoContour; //list for no contours found;
vector<string> myFileListAfterContourSelection; //list for no contours found after selection; vector<string> myFileListAfterContourSelection; //list for no contours found after selection;
cout << "here" << endl;
system("pause");
//loop over all picture of the tar archive, independing how many this are //loop over all picture of the tar archive, independing how many this are
for (;;) for (;;)
{ {
//measure time consumption //measure time consumption
clock_t begin = clock(); //for every single file clock_t begin = clock(); //for every single file
std::vector<char> vec; vector<char> vec;
//we read the next header //we read the next header
r = archive_read_next_header(archive, &entry); r = archive_read_next_header(archive, &entry);
...@@ -254,20 +258,21 @@ int main(int argc, char * argv[]) ...@@ -254,20 +258,21 @@ int main(int argc, char * argv[])
break; break;
if (r != ARCHIVE_OK) if (r != ARCHIVE_OK)
{ {
cerr << "archive_read_next_header: error: "<< archive_error_string(archive) <<" will abort"<< endl; cerr << "archive_read_next_header: error: " << archive_error_string(archive) << " will abort" << endl;
exit(1); exit(1);
} }
cout << "here2" << endl;
// get filename // get filename
const char *fileNamePtr = archive_entry_pathname(entry); const char *fileNamePtr = archive_entry_pathname(entry);
std::string filename(fileNamePtr,strlen(fileNamePtr) ); string filename(fileNamePtr,strlen(fileNamePtr) );
//cout << "fileName: "<< filename <<endl; //cout << "fileName: " << filename <<endl;
// convert it to a framenumber // convert it to a framenumber
frameCounter = toFrameNumber(filename); frameCounter = toFrameNumber(filename);
if(frameCounterOld>frameCounter) if(frameCounterOld>frameCounter)
{ {
cerr <<" error during read in the file number, we do have non montonic order, will abort"; cerr << " error during read in the file number, we do have non montonic order, will abort";
exit(1); exit(1);
} }
...@@ -276,7 +281,7 @@ int main(int argc, char * argv[]) ...@@ -276,7 +281,7 @@ int main(int argc, char * argv[])
r = archive_write_header(ext, entry); r = archive_write_header(ext, entry);
if (r != ARCHIVE_OK) if (r != ARCHIVE_OK)
{ {
cerr<<"archive_write_header() error: "<< archive_error_string(ext)<<endl; cerr<< "archive_write_header() error: " << archive_error_string(ext)<<endl;
myFileTarWriterHeaderCounter++; myFileTarWriterHeaderCounter++;
continue; //we overjump all in our for loop continue; //we overjump all in our for loop
} }
...@@ -288,7 +293,7 @@ int main(int argc, char * argv[]) ...@@ -288,7 +293,7 @@ int main(int argc, char * argv[])
r = archive_write_finish_entry(ext); r = archive_write_finish_entry(ext);
if (r != ARCHIVE_OK) if (r != ARCHIVE_OK)
{ {
cerr<<"archive_write_finish_entry: error: "<< archive_error_string(ext) <<" will abort"<< endl; cerr<< "archive_write_finish_entry: error: " << archive_error_string(ext) << " will abort" << endl;
exit(1); exit(1);
} }
...@@ -296,10 +301,10 @@ int main(int argc, char * argv[]) ...@@ -296,10 +301,10 @@ int main(int argc, char * argv[])
Mat img_input = imdecode(Mat(vec), 1); Mat img_input = imdecode(Mat(vec), 1);
// //we define the type better to prevent error // //we define the type better to prevent error
// fileName = std::string(inputFile + TToolBox::getFileName(frameCounter)); // fileName = string(inputFile + TToolBox::getFileName(frameCounter));
// cv::String fileNameCV(fileName); // cv::String fileNameCV(fileName);
cout <<"\t"<<frameCounter<<"\tof \t"<<amountFiles<<" load file :"<< filename<<endl; cout << "\t" << frameCounter << "\tof \t" << amountFiles << " load file :" << filename << endl;
//of data is present //of data is present
if(img_input.data ) if(img_input.data )
...@@ -329,10 +334,10 @@ int main(int argc, char * argv[]) ...@@ -329,10 +334,10 @@ int main(int argc, char * argv[])
double threshholdMin = 150; double threshholdMin = 150;
double threshholdMax = 200; double threshholdMax = 200;
int apertureSize = 3; int apertureSize = 3;
std::vector<vector<Point> > contours = TToolBox::applyCannyEdgeAndCalcCountours(img_mask,threshholdMin,threshholdMax,apertureSize); vector<vector<Point> > contours = TToolBox::applyCannyEdgeAndCalcCountours(img_mask,threshholdMin,threshholdMax,apertureSize);
//define what we will write down //define what will be written
std::vector<vector<Point> > contourSelection; vector<vector<Point> > contourSelection;
vector<Point2f> massCenters; vector<Point2f> massCenters;
vector<Point> conHull; vector<Point> conHull;
Point2f muConvexHullMassCenter(0.0,0.0); Point2f muConvexHullMassCenter(0.0,0.0);
...@@ -340,10 +345,10 @@ int main(int argc, char * argv[]) ...@@ -340,10 +345,10 @@ int main(int argc, char * argv[])
if(!contours.empty()) if(!contours.empty())
{ {
//! step 4) we make a selection out of all counters with area sizes****************************** //! step 4) we make a selection out of all contours with area sizes******************************
//we calc all min rotated rectangles for all contour from candy egde detect //calc all min rotated rectangles for all contour from canny edge detect
//we exlcude very small one and very big ones //exclude very small/big
vector<RotatedRect> minRect( contours.size() ); vector<RotatedRect> minRect( contours.size() );
//calc boxes around the contours //calc boxes around the contours
...@@ -371,13 +376,13 @@ int main(int argc, char * argv[]) ...@@ -371,13 +376,13 @@ int main(int argc, char * argv[])
//over stepp all small areas //over stepp all small areas
if(area0<areaMinThreshold||area0>areaMaxThreshold) if(area0<areaMinThreshold||area0>areaMaxThreshold)
{ {
//cout<<i<<":area0:"<<area0<<" dismissed "<<endl; //cout<<i<< ":area0:" <<area0<< " dismissed " <<endl;
//skipe if the area is too small //skipe if the area is too small
continue; continue;
} }
else else
{ {
//cout<<i<<":area0:"<<area0<<" choose "<<endl; //cout<<i<< ":area0:" <<area0<< " choose " <<endl;
//get the center of this rectangle //get the center of this rectangle
Point2f center = minRect[i].center; Point2f center = minRect[i].center;
...@@ -438,13 +443,13 @@ int main(int argc, char * argv[]) ...@@ -438,13 +443,13 @@ int main(int argc, char * argv[])
} }
else //end after selection is empty else //end after selection is empty
{ {
cerr<<"error, no contour found after selection in file: "<< filename<<endl; cerr<< "error, no contour found after selection in file: " << filename<<endl;
myFileListAfterContourSelection.push_back(filename); myFileListAfterContourSelection.push_back(filename);
} }
}//end if contours are empty, to canny edge found nothing }//end if contours are empty, to canny edge found nothing
else else
{ {
cerr<<"error, no contour found at all in file: "<< filename<<endl; cerr<< "error, no contour found at all in file: " << filename<<endl;
myFileListNoContour.push_back(filename); myFileListNoContour.push_back(filename);
} }
...@@ -463,29 +468,29 @@ int main(int argc, char * argv[]) ...@@ -463,29 +468,29 @@ int main(int argc, char * argv[])
//we draw it //we draw it
cv::String outpath2= outputDir; cv::String outpath2= outputDir;
std::ostringstream convert2; ostringstream convert2;
convert2 << outpath2 <<TToolBox::mNzero(frameCounter) <<"_convex_hull.jpg"; convert2 << outpath2 << TToolBox::mNzero(frameCounter) << "_convex_hull.jpg";
cv::imwrite(convert2.str().c_str(), imgConvexHull); cv::imwrite(convert2.str().c_str(), imgConvexHull);
} }
else else
cout<<"convex hull has no points will skip file: "<<i<<endl; cout<< "convex hull has no points will skip file: " << i<< endl;
#endif #endif
//cout <<" found center at : "<< massCenters.at(0).x<< ";"<<massCenters.at(0).y<<endl; //cout << " found center at : " << massCenters.at(0).x<< ";" << massCenters.at(0).y<< endl;
//! step 8: we write down all our results in yml file //! step 8: we write down all our results in yml file
std::string nameOutPutFileData = outputDir + TToolBox::mNzero(frameCounter) + ".yml"; string nameOutPutFileData = outputDir + TToolBox::mNzero(frameCounter) + ".yml";
//cout <<"output file:" << nameOutPutFileData; //cout << "output file:" << nameOutPutFileData;
FileStorage fs(nameOutPutFileData.c_str(), FileStorage::WRITE); FileStorage fs(nameOutPutFileData.c_str(), FileStorage::WRITE);
fs << "masscenters" << massCenters; fs << "masscenters" << massCenters;
fs << "polygonselection"<< contourSelection; fs << "polygonselection" << contourSelection;
fs << "convexhull"<<conHull; fs << "convexhull" << conHull;
fs << "masscenterconvexhull"<<muConvexHullMassCenter; fs << "masscenterconvexhull" << muConvexHullMassCenter;
fs.release(); fs.release();
//! we write from time to time a dbg picture //! occasionaly write a dbg picture
if(frameCounter%everyPic==0) if(frameCounter%everyPic==0)
{ {
Scalar colorRed( 0,0,255,255 );//red Scalar colorRed( 0,0,255,255 );//red
...@@ -504,7 +509,7 @@ int main(int argc, char * argv[]) ...@@ -504,7 +509,7 @@ int main(int argc, char * argv[])
circle( imgDebugPaint2, massCenters[i], 4, color, -1, 8, 0 ); circle( imgDebugPaint2, massCenters[i], 4, color, -1, 8, 0 );
} }
//we write the convex hull // write the convex hull
if(!conHull.empty()) if(!conHull.empty())
{ {
//the poly //the poly
...@@ -513,26 +518,26 @@ int main(int argc, char * argv[]) ...@@ -513,26 +518,26 @@ int main(int argc, char * argv[])
circle( imgDebugPaint2,muConvexHullMassCenter, 4, colorRed, -1, 8, 0 ); circle( imgDebugPaint2,muConvexHullMassCenter, 4, colorRed, -1, 8, 0 );
} }
//we make a copy // copy
Mat imgOverlay2 = img_input.clone(); Mat imgOverlay2 = img_input.clone();
//we add a overlay of our paitings // add overlay of paintings
addWeighted( imgDebugPaint2, 0.7, imgOverlay2, 0.3, 0.0, imgOverlay2); addWeighted( imgDebugPaint2, 0.7, imgOverlay2, 0.3, 0.0, imgOverlay2);
//we write the file down // writeout file
std::string nameOutPutFileDBGpic = outputDir + TToolBox::mNzero(frameCounter) + std::string(".jpg"); string nameOutPutFileDBGpic = outputDir + TToolBox::mNzero(frameCounter) + string(".jpg");
imwrite(nameOutPutFileDBGpic.c_str(),imgOverlay2); imwrite(nameOutPutFileDBGpic.c_str(),imgOverlay2);
}//end if we write a dbg picture }//end if dbg picture
}//end if the loaded picture has data }//end if the loaded picture has data
else else
{ {
cerr<<"error loading file: "<< filename<<", will skip this file"<<endl; cerr<< "error loading file: " << filename<< ", will skip this file" << endl;
myFileErrorList.push_back(filename); myFileErrorList.push_back(filename);
} }
//calc the time which we used for a picture //calc the time which we used for a picture //TODO move out of loop
clock_t end = clock(); clock_t end = clock();
double elapsedSecs = double(end - begin) / CLOCKS_PER_SEC; double elapsedSecs = double(end - begin) / CLOCKS_PER_SEC;
...@@ -540,7 +545,7 @@ int main(int argc, char * argv[]) ...@@ -540,7 +545,7 @@ int main(int argc, char * argv[])
//calc the time which was used for all pictures //calc the time which was used for all pictures
clock_t endAll = clock(); clock_t endAll = clock();
double elapsedSecTotal = double(endAll - beginAll) / CLOCKS_PER_SEC; double elapsedSecTotal = double(endAll - beginAll) / CLOCKS_PER_SEC;
cout <<"process single pic:\t"<<elapsedSecs<<" s - \t\t"<<(int)(elapsedSecTotal/60)<<" min -\t"<<(int)(elapsedSecTotal/60/60)<<" h"<<endl; cout << "process single pic:\t" << elapsedSecs<< " s - \t\t" << (int)(elapsedSecTotal/60)<< " min -\t" << (int)(elapsedSecTotal/60/60)<< " h" << endl;
if(g_badSignalFlagAbort) if(g_badSignalFlagAbort)
frameCounter = amountFiles; //we abort frameCounter = amountFiles; //we abort
...@@ -552,38 +557,38 @@ int main(int argc, char * argv[]) ...@@ -552,38 +557,38 @@ int main(int argc, char * argv[])
//finishing time //finishing time
clock_t endAll = clock(); clock_t endAll = clock();
double elapsed = double(endAll - beginAll) / CLOCKS_PER_SEC; double elapsed = double(endAll - beginAll) / CLOCKS_PER_SEC;
cout <<"process : "<<amountFiles<<" files took:\t"<<(int)(elapsed/60)<<" min -\t"<<(int)(elapsed/60/60)<<" h \n in total"<<endl; cout << "process : " << amountFiles<< " files took:\t" << (int)(elapsed/60)<< " min -\t" << (int)(elapsed/60/60)<< " h \n in total" << endl;
// //we write the random file list to a file // //we write the random file list to a file
// std::string nameOutRandomFile = outputDir + "randlist.yml"; // string nameOutRandomFile = outputDir + "randlist.yml";
// FileStorage fs(nameOutRandomFile.c_str(), FileStorage::WRITE); // FileStorage fs(nameOutRandomFile.c_str(), FileStorage::WRITE);
// fs << "randomlist" << myRandomTrainList; // fs << "randomlist" << myRandomTrainList;
// fs.release(); // fs.release();
//TODO we should merge the file //TODO we should merge the file
cout<< "amount of libarchive read header errors :"<< myFileTarWriterHeaderCounter; cout<< "amount of libarchive read header errors :" << myFileTarWriterHeaderCounter;
//we write the random file list to a file // write the random file list to a file
std::string nameOutErrorList = outputDir + "fileErrorList.yml"; string nameOutErrorList = outputDir + "fileErrorList.yml";
cout <<"amount of file errors: "<< myFileErrorList.size()<<endl; cout << "amount of file errors: " << myFileErrorList.size()<< endl;
FileStorage fs2(nameOutErrorList.c_str(), FileStorage::WRITE); FileStorage fs2(nameOutErrorList.c_str(), FileStorage::WRITE);
fs2 << "fileErrorIOs" << myFileErrorList; fs2 << "fileErrorIOs" << myFileErrorList;
//we write error list no contours found in file // write error list no contours found in file
cout <<"amount contour errors with canny edge: "<< myFileListNoContour.size()<<endl; cout << "amount contour errors with canny edge: " << myFileListNoContour.size() << endl;
fs2 << "fileErrorNoContours" << myFileListNoContour; fs2 << "fileErrorNoContours" << myFileListNoContour;
//we write error list no contours found in file // write error list no contours found in file
cout <<"amount contour errors after selection: "<< myFileListAfterContourSelection.size()<<endl; cout << "amount contour errors after selection: " << myFileListAfterContourSelection.size() << endl;
fs2 << "fileErrorNoContoursAfterSelections" << myFileListAfterContourSelection; fs2 << "fileErrorNoContoursAfterSelections" << myFileListAfterContourSelection;
//the bgs related things // bgs related things
delete bgs; delete bgs;
//opencv related things // opencv related things
fs2.release(); fs2.release();
// capture.release();
cvDestroyAllWindows(); cvDestroyAllWindows();
//close lib archive related things //close lib archive related things
...@@ -598,11 +603,11 @@ int main(int argc, char * argv[]) ...@@ -598,11 +603,11 @@ int main(int argc, char * argv[])
std::vector<char> copyDataInBuffer(struct archive *aw) vector<char> copyDataInBuffer(struct archive *aw)
{ {
int r; int r;
const void *buff; const void *buff;
std::vector<char> vec; vector<char> vec;
size_t size; size_t size;
#if ARCHIVE_VERSION_NUMBER >= 3000000 #if ARCHIVE_VERSION_NUMBER >= 3000000
int64_t offset; int64_t offset;
...@@ -641,13 +646,13 @@ void my_handler(int signum) ...@@ -641,13 +646,13 @@ void my_handler(int signum)
if (signum == SIGUSR1) if (signum == SIGUSR1)
{ {
g_badSignalFlagAbort = 1; g_badSignalFlagAbort = 1;
cerr << "receive signal to abort"<<endl; cerr << "receive signal to abort" << endl;
} }
} }
char* getCmdOption(char ** begin, char ** end, const std::string & option) char* getCmdOption(char ** begin, char ** end, const string & option)
{ {
char ** itr = std::find(begin, end, option); char ** itr = find(begin, end, option);
if (itr != end && ++itr != end) if (itr != end && ++itr != end)
{ {
return *itr; return *itr;
...@@ -655,12 +660,12 @@ char* getCmdOption(char ** begin, char ** end, const std::string & option) ...@@ -655,12 +660,12 @@ char* getCmdOption(char ** begin, char ** end, const std::string & option)
return 0; return 0;
} }
bool cmdOptionExists(char** begin, char** end, const std::string& option) bool cmdOptionExists(char** begin, char** end, const string& option)
{ {
return std::find(begin, end, option) != end; return find(begin, end, option) != end;
} }
int toFrameNumber(std::string filename) int toFrameNumber(string filename)
{ {
int retVal = -1; int retVal = -1;
...@@ -670,9 +675,9 @@ int toFrameNumber(std::string filename) ...@@ -670,9 +675,9 @@ int toFrameNumber(std::string filename)
filename = regex_replace(filename, regex("jpg"), ""); filename = regex_replace(filename, regex("jpg"), "");
filename = regex_replace(filename, regex("\\."), ""); filename = regex_replace(filename, regex("\\."), "");
retVal = std::stoi( filename ); retVal = stoi( filename );
//cout <<"filename out:" << filename << " number: "<< retVal << endl; //cout << "filename out:" << filename << " number: " << retVal << endl;
return retVal; return retVal;
} }
opencv 0 → 100644
point2f(y,x) # inverted!
Types:
#depth
CV_8U unsigned char
CV_8S char
CV_16U unsigned short
CV_16S short
CV_32S int
CV_32F float
CV_64F double
# + channels C1..4 eg RGBA:
Camera Calibration:
distortion_coefficients - 5 values
camera_matrix - 3x3 matrix - eg focal length etc.
might need to calibrate using chess board, to get values
sa
https://github.com/abidrahmank/OpenCV2-Python-Tutorials/blob/master/source/py_tutorials/py_calib3d/py_calibration/py_calibration.rst
roi - region of interest - x, y, w, h
BS:
https://docs.opencv.org/4.x/d1/dc5/tutorial_background_subtraction.html
https://web.archive.org/web/20140418093037/http://bmc.univ-bpclermont.fr/
https://web.archive.org/web/20140221195750/http://docs.opencv.org/trunk/doc/tutorials/video/background_subtraction/background_subtraction.html
https://www.pyimagesearch.com/2020/07/27/opencv-grabcut-foreground-segmentation-and-extraction/
https://learnopencv.com/applications-of-foreground-background-separation-with-semantic-segmentation/
https://docs.opencv.org/4.x/d2/d55/group__bgsegm.html
tuts:))
https://docs.opencv.org/4.x/d6/d00/tutorial_py_root.html
...@@ -47,7 +47,7 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv: ...@@ -47,7 +47,7 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv:
#ifdef MC_SHOW_STEP_ANALYSE #ifdef MC_SHOW_STEP_ANALYSE
// Draw contours on extra mat // Draw contours on extra mat
cv::Mat imgContour = cv::Mat::zeros( imgCannyEdge.size(), CV_8UC3 ); cv::Mat imgContour = cv::Mat::zeros( imgCannyEdge.size(), CV_8UC3 );
imgContour = cv::Scalar(255,255,255); //fille the picture imgContour = cv::Scalar(255,255,255); //fill the picture
cv::RNG rng(232323); cv::RNG rng(232323);
for( size_t i = 0; i< contours.size(); i++ ) for( size_t i = 0; i< contours.size(); i++ )
{ {
...@@ -57,8 +57,8 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv: ...@@ -57,8 +57,8 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv:
cv::drawContours( imgContour, contours, i, color, 1, cv::LINE_AA, hierarchy, 0, cv::Point() ); cv::drawContours( imgContour, contours, i, color, 1, cv::LINE_AA, hierarchy, 0, cv::Point() );
} }
// bgslibrary-bgslib_qtgui_2.0.0
cv::String outpath= "/homes/tb55xemi/work/dev/bgslibrary-bgslib_qtgui_2.0.0/build/test0815/results"; cv::String outpath = "./";
std::ostringstream convert; std::ostringstream convert;
convert << outpath << "test_countour_canny_edge.jpg"; convert << outpath << "test_countour_canny_edge.jpg";
cv::imwrite(convert.str().c_str(), imgContour); cv::imwrite(convert.str().c_str(), imgContour);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment