Migration vers OpenCV4

This commit is contained in:
Arnaud Vergnet 2021-03-02 19:09:24 +01:00
parent 34c4234942
commit 5f99ea9f0e
2 changed files with 6 additions and 6 deletions

View file

@ -52,9 +52,9 @@ bool Camera::Open() {
#ifdef __FOR_PC__ #ifdef __FOR_PC__
if (this->cap.open(0)) { if (this->cap.open(0)) {
//this->cap.set(CV_CAP_PROP_FORMAT, CV_8UC3); //this->cap.set(CAP_PROP_FORMAT, CV_8UC3);
this->cap.set(CV_CAP_PROP_FRAME_WIDTH, width); this->cap.set(CAP_PROP_FRAME_WIDTH, width);
this->cap.set(CV_CAP_PROP_FRAME_HEIGHT, height); this->cap.set(CAP_PROP_FRAME_HEIGHT, height);
status = true; status = true;
} }

View file

@ -239,11 +239,11 @@ Arena Img::SearchArena() {
std::vector<cv::Vec4i> hierarchy; std::vector<cv::Vec4i> hierarchy;
ImageMat imageTrt; ImageMat imageTrt;
cv::cvtColor(this->img, imageTrt, CV_RGB2GRAY); // conversion en niveau de gris 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::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 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)); findContours(imageTrt, contours, hierarchy, cv::RETR_TREE, cv::CHAIN_APPROX_SIMPLE, cv::Point(0, 0));
for (unsigned int i = 0; i < contours.size(); i++) { for (unsigned int i = 0; i < contours.size(); i++) {
approxPolyDP(ImageMat(contours[i]), approx, cv::arcLength(ImageMat(contours[i]), true) * 0.1, true); approxPolyDP(ImageMat(contours[i]), approx, cv::arcLength(ImageMat(contours[i]), true) * 0.1, true);
if (approx.size() == 4 && fabs(cv::contourArea(contours[i])) > 100000) { if (approx.size() == 4 && fabs(cv::contourArea(contours[i])) > 100000) {