Possibilité de désactiver opencv4 avec cmake
This commit is contained in:
parent
5f99ea9f0e
commit
d18621f6eb
3 changed files with 21 additions and 10 deletions
|
@ -27,7 +27,7 @@ add_library(lib
|
|||
)
|
||||
target_include_directories(lib PUBLIC lib)
|
||||
target_link_libraries(lib base64)
|
||||
target_compile_definitions(lib PUBLIC __FOR_PC__ __SIMULATION__ __WITH_ARUCO__)
|
||||
target_compile_definitions(lib PUBLIC __FOR_PC__ __SIMULATION__ __WITH_ARUCO__ __WITH_OPENCV4__)
|
||||
|
||||
# Compile main executable
|
||||
add_executable(main main.cpp tasks.cpp tasks.h)
|
||||
|
|
|
@ -52,10 +52,15 @@ bool Camera::Open() {
|
|||
|
||||
#ifdef __FOR_PC__
|
||||
if (this->cap.open(0)) {
|
||||
#ifdef __WITH_OPENCV4__
|
||||
//this->cap.set(CAP_PROP_FORMAT, CV_8UC3);
|
||||
this->cap.set(CAP_PROP_FRAME_WIDTH, width);
|
||||
this->cap.set(CAP_PROP_FRAME_HEIGHT, height);
|
||||
|
||||
#else
|
||||
//this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3);
|
||||
this->cap.set(CV_CAP_PROP_FRAME_WIDTH, width);
|
||||
this->cap.set(CV_CAP_PROP_FRAME_HEIGHT, height);
|
||||
#endif /* __WITH_OPENCV4__ */
|
||||
status = true;
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -239,11 +239,17 @@ Arena Img::SearchArena() {
|
|||
std::vector<cv::Vec4i> hierarchy;
|
||||
|
||||
ImageMat imageTrt;
|
||||
#ifdef __WITH_OPENCV4__
|
||||
cv::cvtColor(this->img, imageTrt, cv::COLOR_RGB2GRAY); // conversion en niveau de gris
|
||||
cv::threshold(imageTrt, imageTrt, 128, 255, cv::THRESH_BINARY); // Threshold les éléments les plus clair
|
||||
cv::Canny(imageTrt, imageTrt, 100, 200, 3); // detection d'angle
|
||||
|
||||
findContours(imageTrt, contours, hierarchy, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
|
||||
#else
|
||||
cv::cvtColor(this->img, imageTrt, CV_RGB2GRAY); // conversion en niveau de gris
|
||||
cv::threshold(imageTrt, imageTrt, 128, 255, CV_THRESH_BINARY); // Threshold les éléments les plus clair
|
||||
cv::Canny(imageTrt, imageTrt, 100, 200, 3); // detection d'angle
|
||||
findContours(imageTrt, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
|
||||
#endif
|
||||
for (unsigned int i = 0; i < contours.size(); i++) {
|
||||
approxPolyDP(ImageMat(contours[i]), approx, cv::arcLength(ImageMat(contours[i]), true) * 0.1, true);
|
||||
if (approx.size() == 4 && fabs(cv::contourArea(contours[i])) > 100000) {
|
||||
|
|
Loading…
Reference in a new issue