Ask Your Question

esteban.da's profile - activity

2019-12-17 01:40:14 -0600 asked a question Error building opencv with sfm module

Error building opencv with sfm module Hy, I have download the opencv and opencv_contrib sources from git and I'm trying

2017-07-24 03:07:55 -0600 asked a question Delaunay triangulation and Point3f

Hy,

I'm trying to create a delaunay triangulation from a set of point 3f. The 2 first coordinates are the coordinates in the plan and the third one is the value of my data at that point (the goal is to create isolines).

I have tried to use SubDiv2D but the problem is that it take point 2f and return a list of Vec6f and so I have to find the association of each point2f with my point3f. Is there a way to get the indice from the vector of input instead of the coordinates ?

Thanks

2016-10-01 12:31:17 -0600 received badge  Scholar (source)
2016-10-01 10:48:11 -0600 asked a question Problem with contourArea return value

Hello, I'm trying to use the contourArea fonction in ordre to remove the "too small" shapes but when I'm running the above code I'm obtaining this king of results : "contour 1 color 125 area 1" or more generally "countour n color x area n". So si there someone having an idea about why I obtain the number of the contour instead of the real area delimitate by the contour ?

Thank you all by advance

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace cv;
using namespace std;

void drawStuff(int, void*);
void showInputWindow();
void showCannyWindow();
void showContourWindow();

int lowThreshold;
int const max_lowThreshold = 100;
const char* window_name = "Edge Map";

int thresh = 40;
int max_thresh = 120;
Mat img_rgb,img_gray,img_bw,canny_output,drawing;

int main(int argc, char *argv[]){
    img_rgb  = imread(argv[1]);
    blur( img_rgb, img_rgb, Size(3,3) );
    namedWindow( window_name, WINDOW_AUTOSIZE );
    cv::createTrackbar( "Min Threshold:", window_name, &lowThreshold, max_lowThreshold, drawStuff );

    drawStuff(0,0);
    cv::waitKey(0);
}

void drawStuff(int, void*){
    vector<vector<Point> > contours;
    vector<Vec4i> hierarchy;

    Canny( img_rgb, canny_output, lowThreshold, lowThreshold*2, 3 );
    cv::dilate(canny_output, canny_output, cv::Mat(), cv::Point(-1,-1));
    showCannyWindow();

    findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
    drawing = Mat::zeros( canny_output.size(), CV_8UC3 );

    vector<Point> approxShape;
    vector<double> areas;
    for(size_t i = 0; i < contours.size(); i++){
            approxPolyDP(contours[i], approxShape, arcLength(Mat(contours[i]), true)*0.04, true);
        areas.push_back(contourArea(contours[i],false));
            drawContours(drawing, contours, i, Scalar((i+1)*10%255, (i+1)*10%255, (i+1)*10%255), CV_FILLED);   // fill one gray per contour
        printf("contour %d color %d area%d\n",i,(i+i)*10%255,areas[i]);
    }
    //cv::fastNlMeansDenoising(img_rgb,contours,3,7,21);

    showContourWindow();
}

void showInputWindow(){
    cv::namedWindow("InputImage");
    cv::imshow("InputImage",img_rgb);
}

void showCannyWindow(){
    cv::namedWindow("Canny");
    cv::imshow("Canny",canny_output);
}
void showContourWindow(){
    cv::namedWindow("Fill");
    cv::imshow("Fill",drawing);
}