Skip to content

Commit

Permalink
ci_runner: Added CI executable
Browse files Browse the repository at this point in the history
Co-authored-by: DiegoBalagane <[email protected]>
Co-authored-by: Reinie78 <[email protected]>
  • Loading branch information
3 people committed Jan 18, 2024
1 parent f17bbc9 commit 2e7c609
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ add_executable(${PROJECT_NAME}-demo
src/example.cpp
)

add_executable(${PROJECT_NAME}-ci-runner
src/ci_runner.cpp
)

target_include_directories(${PROJECT_NAME}-demo PUBLIC ${INCLUDE_DIRECTORIES})
target_include_directories(${PROJECT_NAME}-ci-runner PUBLIC ${INCLUDE_DIRECTORIES})

target_link_libraries(${PROJECT_NAME}-demo PRIVATE
${PROJECT_NAME}
Expand All @@ -55,6 +60,14 @@ target_link_libraries(${PROJECT_NAME}-demo PUBLIC
${OpenCV_LIBS}
)

target_link_libraries(${PROJECT_NAME}-ci-runner PRIVATE
${PROJECT_NAME}
)

target_link_libraries(${PROJECT_NAME}-ci-runner PUBLIC
v4l2
${OpenCV_LIBS}
)

if(ADD_GRABTHECAM_FARSHOW_DEMO)
find_package(farshow QUIET)
Expand Down
34 changes: 34 additions & 0 deletions src/ci_runner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "grabthecam/cameracapture.hpp"
#include "grabthecam/cameracapturetemplates.hpp"
#include "grabthecam/frameconverters/anyformat2bgrconverter.hpp"
#include "grabthecam/frameconverters/packedformats2rgbconverter.hpp"
#include "grabthecam/frameconverters/bayer2bgrconverter.hpp"
#include "grabthecam/frameconverters/yuv2bgrconverter.hpp"
#include "grabthecam/pixelformatsinfo.hpp"
#include <opencv2/imgproc.hpp>

#include "grabthecam/utils.hpp"

int main(int argc, char** argv) {
if(argc < 2) {
std::cout << "Please give a video device path as an argument\n";
exit(1);
}
grabthecam::CameraCapture camera(argv[1]);
int iterator = 0;
for (const auto& entry : grabthecam::formats_info) {
camera.setFormat(1280, 720, entry.first);
cv::Mat frame = camera.capture();
char name[5] = {
(char)((uint32_t)(entry.first ) & 0xff),
(char)((uint32_t)(entry.first >> 8 ) & 0xff),
(char)((uint32_t)(entry.first >> 16 ) & 0xff),
(char)((uint32_t)(entry.first >> 24 ) & 0xff),
0
};
std::string filename = "frame_" + std::string(name) + ".png";
++iterator;
grabthecam::saveToFile(filename, frame);
}
return 0;
}

0 comments on commit 2e7c609

Please sign in to comment.