CameraCalibrarion support for sv::Camera
This commit is contained in:
parent
05538095e3
commit
43deec9daa
|
@ -293,7 +293,7 @@ target_link_libraries(EvalModelOnCocoVal sv_world)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/samples/calib)
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/samples/calib)
|
||||||
add_executable(CameraCalibrarion samples/calib/calibrate_camera_charuco.cpp)
|
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}")
|
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
|
||||||
if (NOT DEFINED SV_INSTALL_PREFIX)
|
if (NOT DEFINED SV_INSTALL_PREFIX)
|
||||||
|
|
|
@ -36,6 +36,7 @@ the use of this software, even if advised of the possibility of such damage.
|
||||||
#include <opencv2/imgproc.hpp>
|
#include <opencv2/imgproc.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sv_world.h>
|
||||||
#include "aruco_samples_utility.hpp"
|
#include "aruco_samples_utility.hpp"
|
||||||
|
|
||||||
using namespace std;
|
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}"
|
"DICT_7X7_100=13, DICT_7X7_250=14, DICT_7X7_1000=15, DICT_ARUCO_ORIGINAL = 16}"
|
||||||
"{cd | | Input file with custom dictionary }"
|
"{cd | | Input file with custom dictionary }"
|
||||||
"{@outfile |<none> | Output file with calibrated camera parameters }"
|
"{@outfile |<none> | 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) }"
|
"{ci | 0 | Camera id if input doesnt come from video (-v) }"
|
||||||
"{dp | | File of marker detector parameters }"
|
"{dp | | File of marker detector parameters }"
|
||||||
"{rs | false | Apply refind strategy }"
|
"{rs | false | Apply refind strategy }"
|
||||||
|
@ -107,26 +111,47 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
bool refindStrategy = parser.get<bool>("rs");
|
bool refindStrategy = parser.get<bool>("rs");
|
||||||
int camId = parser.get<int>("ci");
|
int camId = parser.get<int>("ci");
|
||||||
String video;
|
int imW = 800;
|
||||||
|
int imH = 600;
|
||||||
|
int fps = 30;
|
||||||
|
int tp = 1;
|
||||||
|
|
||||||
if(parser.has("v")) {
|
if(parser.has("imh")) {
|
||||||
video = parser.get<String>("v");
|
imH = parser.get<int>("imh");
|
||||||
}
|
}
|
||||||
|
if(parser.has("imw")) {
|
||||||
|
imW = parser.get<int>("imw");
|
||||||
|
}
|
||||||
|
if(parser.has("fps")) {
|
||||||
|
fps = parser.get<int>("fps");
|
||||||
|
}
|
||||||
|
if(parser.has("tp")) {
|
||||||
|
tp = parser.get<int>("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()) {
|
if(!parser.check()) {
|
||||||
parser.printErrors();
|
parser.printErrors();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoCapture inputVideo;
|
// VideoCapture inputVideo;
|
||||||
int waitTime;
|
sv::Camera inputVideo;
|
||||||
if(!video.empty()) {
|
inputVideo.setWH(imW, imH);
|
||||||
inputVideo.open(video);
|
inputVideo.setFps(fps);
|
||||||
waitTime = 0;
|
inputVideo.open(c_type, camId);
|
||||||
} else {
|
|
||||||
inputVideo.open(camId);
|
int waitTime = 10;
|
||||||
waitTime = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
aruco::Dictionary dictionary = aruco::getPredefinedDictionary(0);
|
aruco::Dictionary dictionary = aruco::getPredefinedDictionary(0);
|
||||||
if (parser.has("d")) {
|
if (parser.has("d")) {
|
||||||
|
@ -156,9 +181,9 @@ int main(int argc, char *argv[]) {
|
||||||
vector< Mat > allImgs;
|
vector< Mat > allImgs;
|
||||||
Size imgSize;
|
Size imgSize;
|
||||||
|
|
||||||
while(inputVideo.grab()) {
|
while(1) {
|
||||||
Mat image, imageCopy;
|
Mat image, imageCopy;
|
||||||
inputVideo.retrieve(image);
|
inputVideo.read(image);
|
||||||
|
|
||||||
vector< int > ids;
|
vector< int > ids;
|
||||||
vector< vector< Point2f > > corners, rejected;
|
vector< vector< Point2f > > corners, rejected;
|
||||||
|
|
Loading…
Reference in New Issue