add charuco point detection method
This commit is contained in:
41
main.cpp
41
main.cpp
@ -9,6 +9,8 @@
|
||||
#include "bgremoval.h"
|
||||
#include "normalize.h"
|
||||
#include "log.h"
|
||||
#include "charuco.h"
|
||||
#include "harris.h"
|
||||
|
||||
void cd_to_exe_dir( char *argv[] )
|
||||
{
|
||||
@ -37,7 +39,7 @@ std::vector<cv::Mat> loadImages(char** fileNames)
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
cv::ocl::setUseOpenCL(false);
|
||||
std::cout<<"UVOS Optical lubricant thikness mapper "<<argp_program_version<<std::endl;
|
||||
|
||||
cd_to_exe_dir(argv);
|
||||
|
||||
Config config;
|
||||
@ -45,6 +47,15 @@ int main(int argc, char* argv[])
|
||||
|
||||
Log::level = config.quiet ? Log::WARN : config.verbose ? Log::DEBUG : Log::INFO;
|
||||
|
||||
Log(Log::INFO)<<"UVOS Optical lubricant thikness mapper "<<argp_program_version;
|
||||
|
||||
if(!config.charuco.empty())
|
||||
{
|
||||
createCharucoBoard(config.size, config.charuco);
|
||||
Log(Log::INFO)<<"exporting charuco map";
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector<cv::Mat> inImages = loadImages(config.inFileNames);
|
||||
|
||||
if(inImages.empty())
|
||||
@ -59,7 +70,6 @@ int main(int argc, char* argv[])
|
||||
cv::resizeWindow("Viewer", 960, 500);
|
||||
}
|
||||
|
||||
|
||||
if(config.maps.empty())
|
||||
{
|
||||
cv::Mat mask;
|
||||
@ -85,9 +95,26 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
else Log(Log::WARN)<<"can not read background image from "<<config.bg;
|
||||
}
|
||||
createRemapMap(inImages[0], config.inFileNames[0], mask,
|
||||
config.blockSize, config.apature, config.detectorParameter,
|
||||
config.minSize, config.verbose);
|
||||
std::vector<cv::Point2f > points;
|
||||
std::vector<cv::Point2i> coordiantes;
|
||||
|
||||
if(config.harris)
|
||||
{
|
||||
points = harrisDetectPoints(inImages[0], mask);
|
||||
}
|
||||
else
|
||||
{
|
||||
points = detectCharucoPoints(inImages[0], &coordiantes);
|
||||
}
|
||||
|
||||
Log(Log::INFO)<<"Found "<<points.size()<<" points";
|
||||
if(points.size() < 8)
|
||||
{
|
||||
Log(Log::ERROR)<<"Error creating map, insufficant points detected";
|
||||
return -1;
|
||||
}
|
||||
|
||||
createRemapMap(inImages[0], points, coordiantes, config.inFileNames[0], config.verbose);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -110,7 +137,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
Log(Log::WARN)<<"could not open normalize file " <<config.norm;
|
||||
}
|
||||
applyRemap(tmp, norm, xMat, yMat, 500);
|
||||
applyRemap(tmp, norm, xMat, yMat, config.size);
|
||||
if(config.verbose)
|
||||
{
|
||||
cv::imshow("Viewer", norm );
|
||||
@ -126,7 +153,7 @@ int main(int argc, char* argv[])
|
||||
cv::waitKey(0);
|
||||
}
|
||||
cv::Mat remaped;
|
||||
applyRemap(image, remaped, xMat, yMat, 500);
|
||||
applyRemap(image, remaped, xMat, yMat, config.size);
|
||||
if(norm.data) normalize(remaped, norm);
|
||||
cv::imshow( "Viewer", remaped );
|
||||
cv::waitKey(0);
|
||||
|
Reference in New Issue
Block a user