diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f0ed43..70f8404 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,7 +293,7 @@ target_link_libraries(EvalModelOnCocoVal sv_world) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/samples/calib) add_executable(CameraCalibrarion samples/calib/calibrate_camera_charuco.cpp) -target_link_libraries(CameraCalibrarion ${OpenCV_LIBS}) +target_link_libraries(CameraCalibrarion ${OpenCV_LIBS} sv_world) message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") if (NOT DEFINED SV_INSTALL_PREFIX) diff --git a/samples/calib/calibrate_camera_charuco.cpp b/samples/calib/calibrate_camera_charuco.cpp index 7337dd2..8827404 100644 --- a/samples/calib/calibrate_camera_charuco.cpp +++ b/samples/calib/calibrate_camera_charuco.cpp @@ -36,6 +36,7 @@ the use of this software, even if advised of the possibility of such damage. #include #include #include +#include #include "aruco_samples_utility.hpp" using namespace std; @@ -58,7 +59,10 @@ const char* keys = "DICT_7X7_100=13, DICT_7X7_250=14, DICT_7X7_1000=15, DICT_ARUCO_ORIGINAL = 16}" "{cd | | Input file with custom dictionary }" "{@outfile | | Output file with calibrated camera parameters }" - "{v | | Input from video file, if ommited, input comes from camera }" + "{imh | | Camera Image Height }" + "{imw | | Camera Image Width }" + "{fps | | Camera FPS }" + "{tp | | 1:WEBCAM, 2:V4L2CAM, 3:G1, 4:Q10, 5:MIPI, 6:GX40 }" "{ci | 0 | Camera id if input doesnt come from video (-v) }" "{dp | | File of marker detector parameters }" "{rs | false | Apply refind strategy }" @@ -107,26 +111,47 @@ int main(int argc, char *argv[]) { bool refindStrategy = parser.get("rs"); int camId = parser.get("ci"); - String video; + int imW = 800; + int imH = 600; + int fps = 30; + int tp = 1; - if(parser.has("v")) { - video = parser.get("v"); + if(parser.has("imh")) { + imH = parser.get("imh"); } + if(parser.has("imw")) { + imW = parser.get("imw"); + } + if(parser.has("fps")) { + fps = parser.get("fps"); + } + if(parser.has("tp")) { + tp = parser.get("tp"); + } + sv::CameraType c_type = sv::CameraType::WEBCAM; + if (2 == tp) + c_type = sv::CameraType::V4L2CAM; + else if (3 == tp) + c_type = sv::CameraType::G1; + else if (4 == tp) + c_type = sv::CameraType::Q10; + else if (5 == tp) + c_type = sv::CameraType::MIPI; + else if (6 == tp) + c_type = sv::CameraType::GX40; if(!parser.check()) { parser.printErrors(); return 0; } - VideoCapture inputVideo; - int waitTime; - if(!video.empty()) { - inputVideo.open(video); - waitTime = 0; - } else { - inputVideo.open(camId); - waitTime = 10; - } + // VideoCapture inputVideo; + sv::Camera inputVideo; + inputVideo.setWH(imW, imH); + inputVideo.setFps(fps); + inputVideo.open(c_type, camId); + + int waitTime = 10; aruco::Dictionary dictionary = aruco::getPredefinedDictionary(0); if (parser.has("d")) { @@ -156,9 +181,9 @@ int main(int argc, char *argv[]) { vector< Mat > allImgs; Size imgSize; - while(inputVideo.grab()) { + while(1) { Mat image, imageCopy; - inputVideo.retrieve(image); + inputVideo.read(image); vector< int > ids; vector< vector< Point2f > > corners, rejected;