Skip to content
Snippets Groups Projects
Commit 10728286 authored by Mederic Fourmy's avatar Mederic Fourmy
Browse files

Added contrast increase in test apriltag

parent a89b0d2a
No related branches found
No related tags found
1 merge request!233WIP: Apriltag
Pipeline #2379 passed
This commit is part of merge request !233. Comments created here will be created in the context of that merge request.
...@@ -14,7 +14,7 @@ detector parameters: ...@@ -14,7 +14,7 @@ detector parameters:
tag parameters: tag parameters:
tag_family: "tag36h11" tag_family: "tag36h11"
tag_black_border: 1 tag_black_border: 1
tag_width_default: 0.052 # enter -1 here if you want to provide a map of [ tagid : tag_width ], see lines just below tag_width_default: 0.055 # enter -1 here if you want to provide a map of [ tagid : tag_width ], see lines just below
tag widths: tag widths:
#1 : 0.2 #1 : 0.2
......
...@@ -24,24 +24,18 @@ ...@@ -24,24 +24,18 @@
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgproc/imgproc.hpp>
#include "opencv2/opencv.hpp" #include "opencv2/opencv.hpp"
#define CONTRAST
#define IMAGE_OUTPUT #define IMAGE_OUTPUT
bool str_ends_with (std::string const &fullString, std::string const &ending) {
if (fullString.length() >= ending.length()) {
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
} else {
return false;
}
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
/* /*
* HOW TO USE ? * HOW TO USE ?
* For now, just call the executable and append the list of images to be processed * For now, just call the executable and append the list of images to be processed.
* For example, if you want to process only one image located at wolf/bin/images/frame1.jpg * The images must be placed in the root folder of your wolf project.
* and if wolf_root is correctly set. then just run (from wolf/bin) * Ex:
* ./test_apriltag /bin/images/frame1.jpg * ./test_apriltag frame1.jpg frame2.jpg frame3.jpg
*/ */
using namespace wolf; using namespace wolf;
...@@ -89,6 +83,20 @@ int main(int argc, char *argv[]) ...@@ -89,6 +83,20 @@ int main(int argc, char *argv[])
if( frame.data ) //if imread succeeded if( frame.data ) //if imread succeeded
{ {
#ifdef CONTRAST
Scalar alpha = 2.0; // to tune contrast [1-3]
int beta = 0; // to tune lightness [0-100]
// Do the operation new_image(i,j) = alpha*image(i,j) + beta
for( int y = 0; y < frame.rows; y++ ){
for( int x = 0; x < frame.cols; x++ ){
for( int c = 0; c < 3; c++ ){
frame.at<cv::Vec3b>(y,x)[c] = cv::saturate_cast<uchar>( alpha*( frame.at<cv::Vec3b>(y,x)[c] ) + beta );
}
}
}
#endif
CaptureImagePtr cap = std::make_shared<CaptureImage>(ts, sen_cam, frame); CaptureImagePtr cap = std::make_shared<CaptureImage>(ts, sen_cam, frame);
// cap->setType(argv[input]); // only for problem->print() to show img filename // cap->setType(argv[input]); // only for problem->print() to show img filename
cap->setName(argv[input]); cap->setName(argv[input]);
...@@ -125,7 +133,7 @@ int main(int argc, char *argv[]) ...@@ -125,7 +133,7 @@ int main(int argc, char *argv[])
cv::line(img->getImage(), fa->getTagCorners()[3], fa->getTagCorners()[0], cv::Scalar(0, 255, 0)); cv::line(img->getImage(), fa->getTagCorners()[3], fa->getTagCorners()[0], cv::Scalar(0, 255, 0));
} }
cv::imshow( img->getName(), img->getImage() ); // display original image. cv::imshow( img->getName(), img->getImage() ); // display original image.
cv::waitKey(1); cv::waitKey(0.1);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment