1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-25 21:33:04 +04:00

Merge branch 4.x

This commit is contained in:
Alexander Smorkalov
2023-06-01 09:37:38 +03:00
565 changed files with 84396 additions and 17589 deletions
@@ -26,26 +26,28 @@ int max_Trackbar = 5;
/// Function Headers
void MatchingMethod( int, void* );
const char* keys =
"{ help h| | Print help message. }"
"{ @input1 | Template_Matching_Original_Image.jpg | image_name }"
"{ @input2 | Template_Matching_Template_Image.jpg | template_name }"
"{ @input3 | | mask_name }";
/**
* @function main
*/
int main( int argc, char** argv )
{
if (argc < 3)
{
cout << "Not enough parameters" << endl;
cout << "Usage:\n" << argv[0] << " <image_name> <template_name> [<mask_name>]" << endl;
return -1;
}
CommandLineParser parser( argc, argv, keys );
samples::addSamplesDataSearchSubDirectory( "doc/tutorials/imgproc/histograms/template_matching/images" );
//! [load_image]
/// Load image and template
img = imread( argv[1], IMREAD_COLOR );
templ = imread( argv[2], IMREAD_COLOR );
img = imread( samples::findFile( parser.get<String>("@input1") ) );
templ = imread( samples::findFile( parser.get<String>("@input2") ), IMREAD_COLOR );
if(argc > 3) {
use_mask = true;
mask = imread( argv[3], IMREAD_COLOR );
mask = imread(samples::findFile( parser.get<String>("@input3") ), IMREAD_COLOR );
}
if(img.empty() || templ.empty() || (use_mask && mask.empty()))
@@ -26,8 +26,9 @@ void Hist_and_Backproj(int, void* );
int main( int argc, char* argv[] )
{
//! [Read the image]
CommandLineParser parser( argc, argv, "{@input | | input image}" );
Mat src = imread( parser.get<String>( "@input" ) );
CommandLineParser parser( argc, argv, "{@input |Back_Projection_Theory0.jpg| input image}" );
samples::addSamplesDataSearchSubDirectory("doc/tutorials/imgproc/histograms/back_projection/images");
Mat src = imread(samples::findFile(parser.get<String>( "@input" )) );
if( src.empty() )
{
cout << "Could not open or find the image!\n" << endl;
@@ -14,9 +14,9 @@ using namespace cv;
const char* keys =
"{ help h| | Print help message. }"
"{ @input1 | | Path to input image 1. }"
"{ @input2 | | Path to input image 2. }"
"{ @input3 | | Path to input image 3. }";
"{ @input1 |Histogram_Comparison_Source_0.jpg | Path to input image 1. }"
"{ @input2 |Histogram_Comparison_Source_1.jpg | Path to input image 2. }"
"{ @input3 |Histogram_Comparison_Source_2.jpg | Path to input image 3. }";
/**
* @function main
@@ -25,9 +25,10 @@ int main( int argc, char** argv )
{
//! [Load three images with different environment settings]
CommandLineParser parser( argc, argv, keys );
Mat src_base = imread( parser.get<String>("input1") );
Mat src_test1 = imread( parser.get<String>("input2") );
Mat src_test2 = imread( parser.get<String>("input3") );
samples::addSamplesDataSearchSubDirectory( "doc/tutorials/imgproc/histograms/histogram_comparison/images" );
Mat src_base = imread(samples::findFile( parser.get<String>( "@input1" ) ) );
Mat src_test1 = imread(samples::findFile( parser.get<String>( "@input2" ) ) );
Mat src_test2 = imread(samples::findFile( parser.get<String>( "@input3" ) ) );
if( src_base.empty() || src_test1.empty() || src_test2.empty() )
{
cout << "Could not open or find the images!\n" << endl;
@@ -1,9 +1,10 @@
/**
/**
* @brief You will learn how to segment an anisotropic image with a single local orientation by a gradient structure tensor (GST)
* @author Karpushin Vladislav, karpushin@ngs.ru, https://github.com/VladKarpushin
*/
#include <iostream>
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
@@ -21,7 +22,8 @@ int main()
int LowThr = 35; // threshold1 for orientation, it ranges from 0 to 180
int HighThr = 57; // threshold2 for orientation, it ranges from 0 to 180
Mat imgIn = imread("input.jpg", IMREAD_GRAYSCALE);
samples::addSamplesDataSearchSubDirectory("doc/tutorials/imgproc/anisotropic_image_segmentation/images");
Mat imgIn = imread(samples::findFile("gst_input.jpg"), IMREAD_GRAYSCALE);
if (imgIn.empty()) //check whether the image is loaded or not
{
cout << "ERROR : Image cannot be loaded..!!" << endl;
@@ -46,13 +48,18 @@ int main()
//! [combining]
//! [main]
normalize(imgCoherency, imgCoherency, 0, 255, NORM_MINMAX);
normalize(imgOrientation, imgOrientation, 0, 255, NORM_MINMAX);
normalize(imgCoherency, imgCoherency, 0, 255, NORM_MINMAX, CV_8U);
normalize(imgOrientation, imgOrientation, 0, 255, NORM_MINMAX, CV_8U);
imshow("Original", imgIn);
imshow("Result", 0.5 * (imgIn + imgBin));
imshow("Coherency", imgCoherency);
imshow("Orientation", imgOrientation);
imwrite("result.jpg", 0.5*(imgIn + imgBin));
imwrite("Coherency.jpg", imgCoherency);
imwrite("Orientation.jpg", imgOrientation);
//! [main_extra]
waitKey(0);
//! [main_extra]
return 0;
}
//! [calcGST]
@@ -1,8 +1,9 @@
/**
/**
* @brief You will learn how to recover an out-of-focus image by Wiener filter
* @author Karpushin Vladislav, karpushin@ngs.ru, https://github.com/VladKarpushin
*/
#include <iostream>
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
@@ -17,9 +18,9 @@ void calcWnrFilter(const Mat& input_h_PSF, Mat& output_G, double nsr);
const String keys =
"{help h usage ? | | print this message }"
"{image |original.JPG | input image name }"
"{R |53 | radius }"
"{SNR |5200 | signal to noise ratio}"
"{image |original.jpg | input image name }"
"{R |5 | radius }"
"{SNR |100 | signal to noise ratio}"
;
int main(int argc, char *argv[])
@@ -35,6 +36,7 @@ int main(int argc, char *argv[])
int R = parser.get<int>("R");
int snr = parser.get<int>("SNR");
string strInFileName = parser.get<String>("image");
samples::addSamplesDataSearchSubDirectory("doc/tutorials/imgproc/out_of_focus_deblur_filter/images");
if (!parser.check())
{
@@ -43,7 +45,7 @@ int main(int argc, char *argv[])
}
Mat imgIn;
imgIn = imread(strInFileName, IMREAD_GRAYSCALE);
imgIn = imread(samples::findFile( strInFileName ), IMREAD_GRAYSCALE);
if (imgIn.empty()) //check whether the image is loaded or not
{
cout << "ERROR : Image cannot be loaded..!!" << endl;
@@ -69,7 +71,10 @@ int main(int argc, char *argv[])
imgOut.convertTo(imgOut, CV_8U);
normalize(imgOut, imgOut, 0, 255, NORM_MINMAX);
imshow("Original", imgIn);
imshow("Debluring", imgOut);
imwrite("result.jpg", imgOut);
waitKey(0);
return 0;
}
@@ -1,8 +1,9 @@
/**
/**
* @brief You will learn how to remove periodic noise in the Fourier domain
* @author Karpushin Vladislav, karpushin@ngs.ru, https://github.com/VladKarpushin
*/
#include <iostream>
#include "opencv2/highgui.hpp"
#include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp>
@@ -14,15 +15,25 @@ void filter2DFreq(const Mat& inputImg, Mat& outputImg, const Mat& H);
void synthesizeFilterH(Mat& inputOutput_H, Point center, int radius);
void calcPSD(const Mat& inputImg, Mat& outputImg, int flag = 0);
int main()
const String keys =
"{help h usage ? | | print this message }"
"{@image |period_input.jpg | input image name }"
;
int main(int argc, char* argv[])
{
Mat imgIn = imread("input.jpg", IMREAD_GRAYSCALE);
CommandLineParser parser(argc, argv, keys);
string strInFileName = parser.get<String>("@image");
samples::addSamplesDataSearchSubDirectory("doc/tutorials/imgproc/periodic_noise_removing_filter/images");
Mat imgIn = imread(samples::findFile(strInFileName), IMREAD_GRAYSCALE);
if (imgIn.empty()) //check whether the image is loaded or not
{
cout << "ERROR : Image cannot be loaded..!!" << endl;
return -1;
}
imshow("Image corrupted", imgIn);
imgIn.convertTo(imgIn, CV_32F);
//! [main]
@@ -57,7 +68,9 @@ int main()
imwrite("PSD.jpg", imgPSD);
fftshift(H, H);
normalize(H, H, 0, 255, NORM_MINMAX);
imshow("Debluring", imgOut);
imwrite("filter.jpg", H);
waitKey(0);
return 0;
}
@@ -13,8 +13,9 @@ using namespace std;
int main() {
//! [generalized-hough-transform-load-and-setup]
// load source image and grayscale template
Mat image = imread("images/generalized_hough_mini_image.jpg");
Mat templ = imread("images/generalized_hough_mini_template.jpg", IMREAD_GRAYSCALE);
samples::addSamplesDataSearchSubDirectory("doc/tutorials/imgproc/generalized_hough_ballard_guil");
Mat image = imread(samples::findFile("images/generalized_hough_mini_image.jpg"));
Mat templ = imread(samples::findFile("images/generalized_hough_mini_template.jpg"), IMREAD_GRAYSCALE);
// create grayscale image
Mat grayImage;
@@ -105,4 +106,4 @@ int main() {
//! [generalized-hough-transform-draw-results]
return EXIT_SUCCESS;
}
}
@@ -12,6 +12,7 @@
#include <opencv2/imgcodecs.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include "opencv2/objdetect/charuco_detector.hpp"
using namespace cv;
using namespace std;
@@ -20,7 +21,7 @@ class Settings
{
public:
Settings() : goodInput(false) {}
enum Pattern { NOT_EXISTING, CHESSBOARD, CIRCLES_GRID, ASYMMETRIC_CIRCLES_GRID };
enum Pattern { NOT_EXISTING, CHESSBOARD, CHARUCOBOARD, CIRCLES_GRID, ASYMMETRIC_CIRCLES_GRID };
enum InputType { INVALID, CAMERA, VIDEO_FILE, IMAGE_LIST };
void write(FileStorage& fs) const //Write serialization for this class
@@ -29,7 +30,10 @@ public:
<< "BoardSize_Width" << boardSize.width
<< "BoardSize_Height" << boardSize.height
<< "Square_Size" << squareSize
<< "Marker_Size" << markerSize
<< "Calibrate_Pattern" << patternToUse
<< "ArUco_Dict_Name" << arucoDictName
<< "ArUco_Dict_File_Name" << arucoDictFileName
<< "Calibrate_NrOfFrameToUse" << nrFrames
<< "Calibrate_FixAspectRatio" << aspectRatio
<< "Calibrate_AssumeZeroTangentialDistortion" << calibZeroTangentDist
@@ -49,10 +53,13 @@ public:
}
void read(const FileNode& node) //Read serialization for this class
{
node["BoardSize_Width" ] >> boardSize.width;
node["BoardSize_Width"] >> boardSize.width;
node["BoardSize_Height"] >> boardSize.height;
node["Calibrate_Pattern"] >> patternToUse;
node["Square_Size"] >> squareSize;
node["ArUco_Dict_Name"] >> arucoDictName;
node["ArUco_Dict_File_Name"] >> arucoDictFileName;
node["Square_Size"] >> squareSize;
node["Marker_Size"] >> markerSize;
node["Calibrate_NrOfFrameToUse"] >> nrFrames;
node["Calibrate_FixAspectRatio"] >> aspectRatio;
node["Write_DetectedFeaturePoints"] >> writePoints;
@@ -148,6 +155,7 @@ public:
calibrationPattern = NOT_EXISTING;
if (!patternToUse.compare("CHESSBOARD")) calibrationPattern = CHESSBOARD;
if (!patternToUse.compare("CHARUCOBOARD")) calibrationPattern = CHARUCOBOARD;
if (!patternToUse.compare("CIRCLES_GRID")) calibrationPattern = CIRCLES_GRID;
if (!patternToUse.compare("ASYMMETRIC_CIRCLES_GRID")) calibrationPattern = ASYMMETRIC_CIRCLES_GRID;
if (calibrationPattern == NOT_EXISTING)
@@ -199,8 +207,11 @@ public:
}
public:
Size boardSize; // The size of the board -> Number of items by width and height
Pattern calibrationPattern; // One of the Chessboard, circles, or asymmetric circle pattern
Pattern calibrationPattern; // One of the Chessboard, ChArUco board, circles, or asymmetric circle pattern
float squareSize; // The size of a square in your defined unit (point, millimeter,etc).
float markerSize; // The size of a marker in your defined unit (point, millimeter,etc).
string arucoDictName; // The Name of ArUco dictionary which you use in ChArUco pattern
string arucoDictFileName; // The Name of file which contains ArUco dictionary for ChArUco pattern
int nrFrames; // The number of frames to use from the input for calibration
float aspectRatio; // The aspect ratio
int delay; // In case of a video input
@@ -284,9 +295,6 @@ int main(int argc, char* argv[])
fs.release(); // close Settings file
//! [file_read]
//FileStorage fout("settings.yml", FileStorage::WRITE); // write config as YAML
//fout << "Settings" << s;
if (!s.goodInput)
{
cout << "Invalid input detected. Application stopping. " << endl;
@@ -296,12 +304,63 @@ int main(int argc, char* argv[])
int winSize = parser.get<int>("winSize");
float grid_width = s.squareSize * (s.boardSize.width - 1);
if (s.calibrationPattern == Settings::Pattern::CHARUCOBOARD) {
grid_width = s.squareSize * (s.boardSize.width - 2);
}
bool release_object = false;
if (parser.has("d")) {
grid_width = parser.get<float>("d");
release_object = true;
}
//create CharucoBoard
cv::aruco::Dictionary dictionary;
if (s.calibrationPattern == Settings::CHARUCOBOARD) {
if (s.arucoDictFileName == "") {
cv::aruco::PredefinedDictionaryType arucoDict;
if (s.arucoDictName == "DICT_4X4_50") { arucoDict = cv::aruco::DICT_4X4_50; }
else if (s.arucoDictName == "DICT_4X4_100") { arucoDict = cv::aruco::DICT_4X4_100; }
else if (s.arucoDictName == "DICT_4X4_250") { arucoDict = cv::aruco::DICT_4X4_250; }
else if (s.arucoDictName == "DICT_4X4_1000") { arucoDict = cv::aruco::DICT_4X4_1000; }
else if (s.arucoDictName == "DICT_5X5_50") { arucoDict = cv::aruco::DICT_5X5_50; }
else if (s.arucoDictName == "DICT_5X5_100") { arucoDict = cv::aruco::DICT_5X5_100; }
else if (s.arucoDictName == "DICT_5X5_250") { arucoDict = cv::aruco::DICT_5X5_250; }
else if (s.arucoDictName == "DICT_5X5_1000") { arucoDict = cv::aruco::DICT_5X5_1000; }
else if (s.arucoDictName == "DICT_6X6_50") { arucoDict = cv::aruco::DICT_6X6_50; }
else if (s.arucoDictName == "DICT_6X6_100") { arucoDict = cv::aruco::DICT_6X6_100; }
else if (s.arucoDictName == "DICT_6X6_250") { arucoDict = cv::aruco::DICT_6X6_250; }
else if (s.arucoDictName == "DICT_6X6_1000") { arucoDict = cv::aruco::DICT_6X6_1000; }
else if (s.arucoDictName == "DICT_7X7_50") { arucoDict = cv::aruco::DICT_7X7_50; }
else if (s.arucoDictName == "DICT_7X7_100") { arucoDict = cv::aruco::DICT_7X7_100; }
else if (s.arucoDictName == "DICT_7X7_250") { arucoDict = cv::aruco::DICT_7X7_250; }
else if (s.arucoDictName == "DICT_7X7_1000") { arucoDict = cv::aruco::DICT_7X7_1000; }
else if (s.arucoDictName == "DICT_ARUCO_ORIGINAL") { arucoDict = cv::aruco::DICT_ARUCO_ORIGINAL; }
else if (s.arucoDictName == "DICT_APRILTAG_16h5") { arucoDict = cv::aruco::DICT_APRILTAG_16h5; }
else if (s.arucoDictName == "DICT_APRILTAG_25h9") { arucoDict = cv::aruco::DICT_APRILTAG_25h9; }
else if (s.arucoDictName == "DICT_APRILTAG_36h10") { arucoDict = cv::aruco::DICT_APRILTAG_36h10; }
else if (s.arucoDictName == "DICT_APRILTAG_36h11") { arucoDict = cv::aruco::DICT_APRILTAG_36h11; }
else {
cout << "incorrect name of aruco dictionary \n";
return 1;
}
dictionary = cv::aruco::getPredefinedDictionary(arucoDict);
}
else {
cv::FileStorage dict_file(s.arucoDictFileName, cv::FileStorage::Mode::READ);
cv::FileNode fn(dict_file.root());
dictionary.readDictionary(fn);
}
}
else {
// default dictionary
dictionary = cv::aruco::getPredefinedDictionary(0);
}
cv::aruco::CharucoBoard ch_board({s.boardSize.width, s.boardSize.height}, s.squareSize, s.markerSize, dictionary);
cv::aruco::CharucoDetector ch_detector(ch_board);
std::vector<int> markerIds;
vector<vector<Point2f> > imagePoints;
Mat cameraMatrix, distCoeffs;
Size imageSize;
@@ -309,8 +368,8 @@ int main(int argc, char* argv[])
clock_t prevTimestamp = 0;
const Scalar RED(0,0,255), GREEN(0,255,0);
const char ESC_KEY = 27;
//! [get_input]
for(;;)
{
Mat view;
@@ -357,6 +416,10 @@ int main(int argc, char* argv[])
case Settings::CHESSBOARD:
found = findChessboardCorners( view, s.boardSize, pointBuf, chessBoardFlags);
break;
case Settings::CHARUCOBOARD:
ch_detector.detectBoard( view, pointBuf, markerIds);
found = pointBuf.size() == (size_t)((s.boardSize.height - 1)*(s.boardSize.width - 1));
break;
case Settings::CIRCLES_GRID:
found = findCirclesGrid( view, s.boardSize, pointBuf );
break;
@@ -368,8 +431,9 @@ int main(int argc, char* argv[])
break;
}
//! [find_pattern]
//! [pattern_found]
if ( found) // If done with success,
if (found) // If done with success,
{
// improve the found corners' coordinate accuracy for chessboard
if( s.calibrationPattern == Settings::CHESSBOARD)
@@ -389,7 +453,10 @@ int main(int argc, char* argv[])
}
// Draw the corners.
drawChessboardCorners( view, s.boardSize, Mat(pointBuf), found );
if(s.calibrationPattern == Settings::CHARUCOBOARD)
drawChessboardCorners( view, cv::Size(s.boardSize.width-1, s.boardSize.height-1), Mat(pointBuf), found );
else
drawChessboardCorners( view, s.boardSize, Mat(pointBuf), found );
}
//! [pattern_found]
//----------------------------- Output Text ------------------------------------------------
@@ -531,15 +598,25 @@ static void calcBoardCornerPositions(Size boardSize, float squareSize, vector<Po
{
case Settings::CHESSBOARD:
case Settings::CIRCLES_GRID:
for( int i = 0; i < boardSize.height; ++i )
for( int j = 0; j < boardSize.width; ++j )
for (int i = 0; i < boardSize.height; ++i) {
for (int j = 0; j < boardSize.width; ++j) {
corners.push_back(Point3f(j*squareSize, i*squareSize, 0));
}
}
break;
case Settings::CHARUCOBOARD:
for (int i = 0; i < boardSize.height - 1; ++i) {
for (int j = 0; j < boardSize.width - 1; ++j) {
corners.push_back(Point3f(j*squareSize, i*squareSize, 0));
}
}
break;
case Settings::ASYMMETRIC_CIRCLES_GRID:
for( int i = 0; i < boardSize.height; i++ )
for( int j = 0; j < boardSize.width; j++ )
corners.push_back(Point3f((2*j + i % 2)*squareSize, i*squareSize, 0));
for (int i = 0; i < boardSize.height; i++) {
for (int j = 0; j < boardSize.width; j++) {
corners.push_back(Point3f((2 * j + i % 2)*squareSize, i*squareSize, 0));
}
}
break;
default:
break;
@@ -564,7 +641,12 @@ static bool runCalibration( Settings& s, Size& imageSize, Mat& cameraMatrix, Mat
vector<vector<Point3f> > objectPoints(1);
calcBoardCornerPositions(s.boardSize, s.squareSize, objectPoints[0], s.calibrationPattern);
objectPoints[0][s.boardSize.width - 1].x = objectPoints[0][0].x + grid_width;
if (s.calibrationPattern == Settings::Pattern::CHARUCOBOARD) {
objectPoints[0][s.boardSize.width - 2].x = objectPoints[0][0].x + grid_width;
}
else {
objectPoints[0][s.boardSize.width - 1].x = objectPoints[0][0].x + grid_width;
}
newObjPoints = objectPoints[0];
objectPoints.resize(imagePoints.size(),objectPoints[0]);
@@ -635,6 +717,7 @@ static void saveCameraParams( Settings& s, Size& imageSize, Mat& cameraMatrix, M
fs << "board_width" << s.boardSize.width;
fs << "board_height" << s.boardSize.height;
fs << "square_size" << s.squareSize;
fs << "marker_size" << s.markerSize;
if( !s.useFisheye && s.flag & CALIB_FIX_ASPECT_RATIO )
fs << "fix_aspect_ratio" << s.aspectRatio;
@@ -2,15 +2,16 @@
<opencv_storage>
<Settings>
<!-- Number of inner corners per a item row and column. (square, circle) -->
<BoardSize_Width> 9</BoardSize_Width>
<BoardSize_Width>9</BoardSize_Width>
<BoardSize_Height>6</BoardSize_Height>
<!-- The size of a square in some user defined metric system (pixel, millimeter)-->
<Square_Size>50</Square_Size>
<!-- The type of input used for camera calibration. One of: CHESSBOARD CIRCLES_GRID ASYMMETRIC_CIRCLES_GRID -->
<Marker_Size>25</Marker_Size>
<!-- The type of input used for camera calibration. One of: CHESSBOARD CHARUCOBOARD CIRCLES_GRID ASYMMETRIC_CIRCLES_GRID -->
<Calibrate_Pattern>"CHESSBOARD"</Calibrate_Pattern>
<ArUco_Dict_Name>DICT_4X4_50</ArUco_Dict_Name>
<ArUco_Dict_File_Name></ArUco_Dict_File_Name>
<!-- The input to use for calibration.
To use an input camera -> give the ID of the camera, like "1"
To use an input video -> give the path of the input video, like "/tmp/x.avi"
@@ -92,7 +92,7 @@ void Sharpen(const Mat& myImage,Mat& Result)
for(int i= nChannels;i < nChannels*(myImage.cols-1); ++i)
{
*output++ = saturate_cast<uchar>(5*current[i]
output[i] = saturate_cast<uchar>(5*current[i]
-current[i-nChannels] - current[i+nChannels] - previous[i] - next[i]);
}
}
@@ -5,9 +5,9 @@ find_package(OpenCV REQUIRED COMPONENTS opencv_core)
if(NOT OPENCV_EXAMPLES_SKIP_PARALLEL_BACKEND_OPENMP
AND NOT OPENCV_EXAMPLES_SKIP_OPENMP
)
project(opencv_example_openmp_backend)
find_package(OpenMP)
if(OpenMP_FOUND)
project(opencv_example_openmp_backend)
add_executable(opencv_example_openmp_backend example-openmp.cpp)
target_link_libraries(opencv_example_openmp_backend PRIVATE
opencv_core
@@ -20,13 +20,13 @@ if(NOT OPENCV_EXAMPLES_SKIP_PARALLEL_BACKEND_TBB
AND NOT OPENCV_EXAMPLES_SKIP_TBB
AND NOT OPENCV_EXAMPLE_SKIP_TBB # deprecated (to be removed in OpenCV 5.0)
)
project(opencv_example_tbb_backend)
find_package(TBB QUIET)
if(NOT TBB_FOUND)
find_path(TBB_INCLUDE_DIR NAMES "tbb/tbb.h")
find_library(TBB_LIBRARY NAMES "tbb")
endif()
if(TBB_INCLUDE_DIR AND TBB_LIBRARY)
project(opencv_example_tbb_backend)
add_executable(opencv_example_tbb_backend example-tbb.cpp)
target_include_directories(opencv_example_tbb_backend SYSTEM PRIVATE ${TBB_INCLUDE_DIR})
target_link_libraries(opencv_example_tbb_backend PRIVATE
@@ -38,6 +38,8 @@ int main()
waitKey(0);
//! [Algorithm]
const char * vertex_names[4] {"0", "1", "2", "3"};
//! [RotatedRect_demo]
Mat test_image(200, 200, CV_8UC3, Scalar(0));
RotatedRect rRect = RotatedRect(Point2f(100,100), Size2f(100,50), 30);
@@ -45,7 +47,10 @@ int main()
Point2f vertices[4];
rRect.points(vertices);
for (int i = 0; i < 4; i++)
{
line(test_image, vertices[i], vertices[(i+1)%4], Scalar(0,255,0), 2);
putText(test_image, vertex_names[i], vertices[i], FONT_HERSHEY_SIMPLEX, 1, Scalar(255,255,255));
}
Rect brect = rRect.boundingRect();
rectangle(test_image, brect, Scalar(255,0,0), 2);