From 6271e8a7a61044d85305a5330d8c0f3e16db9f3d Mon Sep 17 00:00:00 2001 From: mxochicale Date: Thu, 30 May 2024 23:21:01 +0100 Subject: [PATCH] adds conf_build to opencv/examples/cpp #65 --- .../cpp/Multithread-Camera-OpenCV/README.md | 5 +- .../cpp/Multithread-Camera-OpenCV/conf_build | 16 ++++++ opencv/examples/cpp/hello-world/build.bash | 6 -- opencv/examples/cpp/hello-world/conf_build | 16 ++++++ opencv/examples/cpp/hello-world/main.cpp | 2 +- .../README.md | 8 +-- .../conf_build | 16 ++++++ .../cpp/triangulation_tests/conf_build | 16 ++++++ .../cpp/triangulation_tests/src/main_cpp | 56 ------------------- .../cpp/video-to-ascii-cpp/conf_build | 16 ++++++ .../examples/cpp/videowriter_basic/README.md | 4 +- .../examples/cpp/videowriter_basic/conf_build | 16 ++++++ 12 files changed, 101 insertions(+), 76 deletions(-) create mode 100644 opencv/examples/cpp/Multithread-Camera-OpenCV/conf_build delete mode 100644 opencv/examples/cpp/hello-world/build.bash create mode 100644 opencv/examples/cpp/hello-world/conf_build create mode 100644 opencv/examples/cpp/multi-threaded-video-compression/conf_build create mode 100644 opencv/examples/cpp/triangulation_tests/conf_build delete mode 100644 opencv/examples/cpp/triangulation_tests/src/main_cpp create mode 100644 opencv/examples/cpp/video-to-ascii-cpp/conf_build create mode 100644 opencv/examples/cpp/videowriter_basic/conf_build diff --git a/opencv/examples/cpp/Multithread-Camera-OpenCV/README.md b/opencv/examples/cpp/Multithread-Camera-OpenCV/README.md index 59bd157..d05ef9c 100644 --- a/opencv/examples/cpp/Multithread-Camera-OpenCV/README.md +++ b/opencv/examples/cpp/Multithread-Camera-OpenCV/README.md @@ -11,10 +11,7 @@ v4l2-ctl --list-devices ## Build and run app ``` -rm -rf build && mkdir -p build && cd build -cmake .. && make -./main -rm -rf build/ +bash conf_build ``` ## Gstreamer diff --git a/opencv/examples/cpp/Multithread-Camera-OpenCV/conf_build b/opencv/examples/cpp/Multithread-Camera-OpenCV/conf_build new file mode 100644 index 0000000..da8c644 --- /dev/null +++ b/opencv/examples/cpp/Multithread-Camera-OpenCV/conf_build @@ -0,0 +1,16 @@ + +## Setting paths +source_dir=$PWD +build_dir=${source_dir}/build +rm -rf $ +mkdir -p $build_dir + + +## Configure +#cmake -S ${source_dir} -B ${build_dir} -D CMAKE_BUILD_TYPE=Release +cmake -S ${source_dir} -B ${build_dir} -G Ninja -D CMAKE_BUILD_TYPE=Release + +## Build +cmake --build ${build_dir} -j + +#ctest --test-dir ${build_dir} diff --git a/opencv/examples/cpp/hello-world/build.bash b/opencv/examples/cpp/hello-world/build.bash deleted file mode 100644 index 1ad9b72..0000000 --- a/opencv/examples/cpp/hello-world/build.bash +++ /dev/null @@ -1,6 +0,0 @@ -## how to compile -mkdir build && cd build -cmake .. -make - - diff --git a/opencv/examples/cpp/hello-world/conf_build b/opencv/examples/cpp/hello-world/conf_build new file mode 100644 index 0000000..da8c644 --- /dev/null +++ b/opencv/examples/cpp/hello-world/conf_build @@ -0,0 +1,16 @@ + +## Setting paths +source_dir=$PWD +build_dir=${source_dir}/build +rm -rf $ +mkdir -p $build_dir + + +## Configure +#cmake -S ${source_dir} -B ${build_dir} -D CMAKE_BUILD_TYPE=Release +cmake -S ${source_dir} -B ${build_dir} -G Ninja -D CMAKE_BUILD_TYPE=Release + +## Build +cmake --build ${build_dir} -j + +#ctest --test-dir ${build_dir} diff --git a/opencv/examples/cpp/hello-world/main.cpp b/opencv/examples/cpp/hello-world/main.cpp index a07d005..9d0927d 100644 --- a/opencv/examples/cpp/hello-world/main.cpp +++ b/opencv/examples/cpp/hello-world/main.cpp @@ -4,7 +4,7 @@ int main() { std::cout << "Hello, OpenCV\n"; - cv::Mat image = cv::imread("../lena.png", cv::IMREAD_GRAYSCALE); + cv::Mat image = cv::imread("lena.png", cv::IMREAD_GRAYSCALE); if (image.empty()) { std::cerr << "Image not found\n"; return 1; diff --git a/opencv/examples/cpp/multi-threaded-video-compression/README.md b/opencv/examples/cpp/multi-threaded-video-compression/README.md index 0ab4d28..5dfd887 100644 --- a/opencv/examples/cpp/multi-threaded-video-compression/README.md +++ b/opencv/examples/cpp/multi-threaded-video-compression/README.md @@ -2,15 +2,9 @@ ## Build and run app ``` -rm -rf build && mkdir -p build && cd build -cmake .. && make -./main -rm -rf build/ +bash conf_build ``` - - - ## Reference https://github.com/rbga/Multi-Threaded-Real-Time-Image-and-Video-Compression-using-OpenCV/blob/master/ConsoleApplication1/ConsoleApplication1.cpp diff --git a/opencv/examples/cpp/multi-threaded-video-compression/conf_build b/opencv/examples/cpp/multi-threaded-video-compression/conf_build new file mode 100644 index 0000000..da8c644 --- /dev/null +++ b/opencv/examples/cpp/multi-threaded-video-compression/conf_build @@ -0,0 +1,16 @@ + +## Setting paths +source_dir=$PWD +build_dir=${source_dir}/build +rm -rf $ +mkdir -p $build_dir + + +## Configure +#cmake -S ${source_dir} -B ${build_dir} -D CMAKE_BUILD_TYPE=Release +cmake -S ${source_dir} -B ${build_dir} -G Ninja -D CMAKE_BUILD_TYPE=Release + +## Build +cmake --build ${build_dir} -j + +#ctest --test-dir ${build_dir} diff --git a/opencv/examples/cpp/triangulation_tests/conf_build b/opencv/examples/cpp/triangulation_tests/conf_build new file mode 100644 index 0000000..da8c644 --- /dev/null +++ b/opencv/examples/cpp/triangulation_tests/conf_build @@ -0,0 +1,16 @@ + +## Setting paths +source_dir=$PWD +build_dir=${source_dir}/build +rm -rf $ +mkdir -p $build_dir + + +## Configure +#cmake -S ${source_dir} -B ${build_dir} -D CMAKE_BUILD_TYPE=Release +cmake -S ${source_dir} -B ${build_dir} -G Ninja -D CMAKE_BUILD_TYPE=Release + +## Build +cmake --build ${build_dir} -j + +#ctest --test-dir ${build_dir} diff --git a/opencv/examples/cpp/triangulation_tests/src/main_cpp b/opencv/examples/cpp/triangulation_tests/src/main_cpp deleted file mode 100644 index d57a432..0000000 --- a/opencv/examples/cpp/triangulation_tests/src/main_cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include -#include -#include -using namespace cv; -using namespace std; -int main(int, char**) -{ - Mat src; - // use default camera as video source - VideoCapture cap(0); - // check if we succeeded - if (!cap.isOpened()) { - cerr << "ERROR! Unable to open camera\n"; - return -1; - } - // get one frame from camera to know frame size and type - cap >> src; - // check if we succeeded - if (src.empty()) { - cerr << "ERROR! blank frame grabbed\n"; - return -1; - } - bool isColor = (src.type() == CV_8UC3); - //--- INITIALIZE VIDEOWRITER - VideoWriter writer; - int codec = VideoWriter::fourcc('M', 'J', 'P', 'G'); // select desired codec (must be available at runtime) - double fps = 25.0; // framerate of the created video stream - string filename = "./live.avi"; // name of the output video file - writer.open(filename, codec, fps, src.size(), isColor); - // check if we succeeded - if (!writer.isOpened()) { - cerr << "Could not open the output video file for write\n"; - return -1; - } - //--- GRAB AND WRITE LOOP - cout << "Writing videofile: " << filename << endl - << "Press any key to terminate" << endl; - for (;;) - { - // check if we succeeded - if (!cap.read(src)) { - cerr << "ERROR! blank frame grabbed\n"; - break; - } - // encode the frame into the videofile stream - writer.write(src); - // show live and wait for a key with timeout long enough to show images - imshow("Live", src); - if (waitKey(5) >= 0) - break; - } - // the videofile will be closed and released automatically in VideoWriter destructor - return 0; -} diff --git a/opencv/examples/cpp/video-to-ascii-cpp/conf_build b/opencv/examples/cpp/video-to-ascii-cpp/conf_build new file mode 100644 index 0000000..f990fbf --- /dev/null +++ b/opencv/examples/cpp/video-to-ascii-cpp/conf_build @@ -0,0 +1,16 @@ + +## Setting paths +source_dir=$PWD +build_dir=${source_dir}/build +rm -rf ${build_dir} +mkdir -p $build_dir + + +## Configure +#cmake -S ${source_dir} -B ${build_dir} -G Ninja -D CMAKE_BUILD_TYPE=Release +cmake -S ${source_dir} -B ${build_dir} -G Ninja + +## Build +cmake --build ${build_dir} -j + +#ctest --test-dir ${build_dir} diff --git a/opencv/examples/cpp/videowriter_basic/README.md b/opencv/examples/cpp/videowriter_basic/README.md index 3d2dc11..6866f41 100644 --- a/opencv/examples/cpp/videowriter_basic/README.md +++ b/opencv/examples/cpp/videowriter_basic/README.md @@ -42,13 +42,13 @@ Format Video Capture: ## clean, build and execute ``` -bash build.bash +bash conf_build ``` ## execute ``` -./build/videowriter +./build/main vlc live.avi ``` diff --git a/opencv/examples/cpp/videowriter_basic/conf_build b/opencv/examples/cpp/videowriter_basic/conf_build new file mode 100644 index 0000000..d934fa1 --- /dev/null +++ b/opencv/examples/cpp/videowriter_basic/conf_build @@ -0,0 +1,16 @@ + +## Setting paths +source_dir=$PWD +build_dir=${source_dir}/build +rm -rf ${build_dir} +mkdir -p $build_dir + + +## Configure +cmake -S ${source_dir} -B ${build_dir} -G Ninja -D CMAKE_BUILD_TYPE=Release +#cmake -S ${source_dir} -B ${build_dir} -G Ninja + +## Build +cmake --build ${build_dir} -j + +#ctest --test-dir ${build_dir}