diff --git a/examples/Demo.cpp b/examples/Demo.cpp index 1311d953b580e020c1c32d458f056977f1a1a1cf..c01770ced407e3763b2d56b3cb0dae9a89b7a60e 100644 --- a/examples/Demo.cpp +++ b/examples/Demo.cpp @@ -47,6 +47,13 @@ vector<char> copyDataInBuffer(struct archive *aw); //! we convert our actual jpg file number to framenumber int toFrameNumber(string filename); +//my custom pretty print. For now: just print all elements of a vector +// template<typename T> +void pp(Mat input) +{ + std::cout << input << endl; +} + int main(int argc, char * argv[]) { signal(SIGUSR1, my_handler); @@ -207,35 +214,36 @@ int main(int argc, char * argv[]) fsCen.release(); - cout << "here" << endl; - system("pause"); - - //open camera config file cv::String camParam (cameraParameterFile); - Mat intrinsicsCameraMatrix, distortionCoeff; + // std::vector<int> intrinsicsCameraMatrix; // = {1000, 0, 320, 0, 1000, 240, 0, 0, 1}; + // std::vector<double> distortionCoeff; // = {1000, 0, 320, 0, 1000, 240, 0, 0, 1}; + Mat intrinsicsCameraMatrix; // = {1000, 0, 320, 0, 1000, 240, 0, 0, 1}; + // Mat distortionCoeff; // = {0.1, 0.01, -0.001, 0, 0}; { cout << "read cam parameter of: " << cameraParameterFile << endl; - FileStorage fs; - fs.open(camParam, FileStorage::READ); + FileStorage fs(camParam, FileStorage::READ); if (!fs.isOpened()) { - cerr << "error during open " << cameraParameterFile << " will abort" << endl; + cerr << "error opening '" << cameraParameterFile << "' will abort" << endl; return -1; } - - fs["camera_matrix"] >> intrinsicsCameraMatrix; - fs["distortion_coefficients"] >> distortionCoeff; +// Mat_<double>(3,3) +// Mat_<double>(5,1) + fs["camera_matrix"] >> (Mat_<double>(3,3))intrinsicsCameraMatrix; + // fs["distortion_coefficients"] >> distortionCoeff; // intrinsicsCameraMatrix = (int) fs["camera_matrix"]; // intrinsicsCameraMatrix = fs["camera_matrix"].mat(); - cout << "camera_matrix = " << intrinsicsCameraMatrix << endl; + // cout << "ISMAT?" << intrinsicsCameraMatrix.isMap() << endl; + // pp(intrinsicsCameraMatrix); + // pp(distortionCoeff); - // distortionCoeff = (int) fs["distortion_coefficients"]; - // distortionCoeff = fs["distortion_coefficients"].mat(); - cout << "distortion_coefficients = " << distortionCoeff << endl; } + system( "echo 'sleep a bit... ' && sleep 12" ); + exit(EXIT_SUCCESS); + cout << "a) process all frames " << endl; int everyPic= 60*5; diff --git a/examples/ct-examples.sublime-project b/examples/ct-examples.sublime-project index 37afd6b043bf0cea04aeaba87229983229048735..aaf6fa03ef89766ea7a98ed457af82d33747e3c6 100644 --- a/examples/ct-examples.sublime-project +++ b/examples/ct-examples.sublime-project @@ -32,6 +32,18 @@ "name": "clean", "shell_cmd": "make -j8 clean", }, + { + "name": "run: single", + "shell_cmd": "echo 'run...' && $file_base_name", + }, + { + "name": "opencv: single", + "shell_cmd": "echo 'build opencv single' && echo 'g++ -ggdb $file -o $file_base_name `pkg-config --cflags --libs opencv4`' && g++ -ggdb $file -o $file_base_name `pkg-config --cflags --libs opencv4`", + }, + { + "name": "json parser", + "shell_cmd": "/usr/bin/g++ -std=c++2a -I/usr/include/nlohmann -fconcepts $file && $file_base_name ~/.config/user/bookmarx/bookmarks-m.json ~/.config/user/bookmarx/bookmarks-empty.json | c++filt -t && echo ''", + }, { "name": "install/strip", "shell_cmd": "make -j8 install/strip", diff --git a/install b/install new file mode 100644 index 0000000000000000000000000000000000000000..8ae182baf6ada10ede9ac8d1b42d3940eab2490d --- /dev/null +++ b/install @@ -0,0 +1,5 @@ +g++ -ggdb -o `pkg-config --cflags --libs opencv4` + + +camera_matrix 5678 +distortion_coefficients 76745 diff --git a/opencv b/opencv index 416ab521e566124b2fdbc182e32924cb2c9b1e0c..a8f6d8f5af6686bc865343d9528cde2218953ef6 100644 --- a/opencv +++ b/opencv @@ -21,7 +21,8 @@ Types: -Camera Calibration: +# Camera Calibration: +######################## distortion_coefficients - 5 values camera_matrix - 3x3 matrix - eg focal length etc. @@ -33,14 +34,9 @@ Camera Calibration: https://github.com/abidrahmank/OpenCV2-Python-Tutorials/blob/master/source/py_tutorials/py_calib3d/py_calibration/py_calibration.rs -roi - region of interest - x, y, w, h - - // roi as subset of full data image - Mat D (A, Rect(10, 10, 100, 100) ); // using a rectangle - Mat E = A(Range::all(), Range(1,3)); // using row and column boundaries -Matrix +# Matrices +######################## Fill matrix with random values Mat R = Mat(3, 2, CV_8UC3); randu(R, Scalar::all(0), Scalar::all(255)); @@ -51,7 +47,27 @@ Matrix InputArray = vector or Mat -MISC + type() + create(r,c,t) + copyTo() + clone() for deep copy + cv::Mat F = cv::Mat::ones(3, 4, CV_32FC1) * 3; //all 3's + + traverse: https://programmersought.com/article/72762264465/ + +##roi - region of interest + x, y, w, h + + // roi as subset of full data image + Mat D (A, Rect(10, 10, 100, 100) ); // using a rectangle + Mat E = A(Range::all(), Range(1,3)); // using row and column boundaries + + locateROI, adjustROI, + + + +# MISC +######################## glob( dir, file ) CommandLineParser randu() # https://docs.opencv.org/4.x/d2/de8/group__core__array.html#ga1ba1026dca0807b27057ba6a49d258c0 diff --git a/src/algorithms/ttoolbox.cpp b/src/algorithms/ttoolbox.cpp index cd10965014d9443252e78c6f00114ab03b780e1e..62a36a0b021b0904786c84d97553a68d9a3b3d62 100644 --- a/src/algorithms/ttoolbox.cpp +++ b/src/algorithms/ttoolbox.cpp @@ -63,7 +63,8 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv: } // bgslibrary-bgslib_qtgui_2.0.0 - String outpath = "./"; + cv::String outpath = "./"; + std::ostringstream convert; convert << outpath << "test_countour_canny_edge.jpg"; cv::imwrite(convert.str().c_str(), imgContour); @@ -73,6 +74,8 @@ std::vector<std::vector<cv::Point>> TToolBox::applyCannyEdgeAndCalcCountours(cv: } + + cv::Mat TToolBox::cropImageCircle(cv::Mat image, int x, int y, int r) {