Ask Your Question

pklab's profile - activity

2020-11-16 15:36:08 -0600 received badge  Great Answer (source)
2020-11-16 15:36:08 -0600 received badge  Guru (source)
2020-10-23 09:38:41 -0600 received badge  Good Answer (source)
2019-07-01 22:10:33 -0600 received badge  Nice Answer (source)
2018-06-18 20:05:02 -0600 received badge  Good Answer (source)
2018-01-04 14:04:45 -0600 received badge  Nice Answer (source)
2018-01-04 12:18:49 -0600 received badge  Civic Duty (source)
2018-01-04 11:16:23 -0600 received badge  Necromancer (source)
2018-01-04 10:52:17 -0600 answered a question Destination image size of LinearPolar / LogPolar

a bit late but I've just submitted a pullrequest (https://github.com/opencv/opencv/pull/10505) to add the required funct

2017-10-26 18:56:28 -0600 received badge  Nice Answer (source)
2017-10-14 02:52:00 -0600 commented answer How to create "list<Mat>" in 3.0?

@opalmirror you are welcome .... enthusiasm is an ingredient for knowledge :)

2017-10-10 12:33:00 -0600 commented answer How to create "list<Mat>" in 3.0?

@opalmirror there is no reason to delete your comment but I can advise to write comment or answer only when you well kno

2017-10-08 11:09:38 -0600 received badge  Nice Answer (source)
2017-10-07 02:23:50 -0600 commented answer How to create "list<Mat>" in 3.0?

@opalmirror I'm not full understand your point but I think your suggestion is not applicable to the question. The point

2017-10-07 02:22:37 -0600 commented answer How to create "list<Mat>" in 3.0?

@opalmirror I'm not full understand your point but I think your suggestion is not applicable to the question. The point

2017-10-06 04:55:31 -0600 commented question How do I follow the detected line and find more points connected to it?

check HoughLines, Tutorial

2017-10-06 04:33:09 -0600 received badge  Necromancer (source)
2017-10-06 04:24:54 -0600 commented question Using multithreading in opencv

double quote berak naive multithreading & global variables -- just don't ! plus mine multithreading without strong b

2017-10-06 04:22:30 -0600 answered a question How to create "list<Mat>" in 3.0?

I would bring up this question because @berak's answer would compiles but it really should be used with care. For examp

2017-09-04 13:17:10 -0600 received badge  Nice Answer (source)
2017-09-02 03:08:56 -0600 commented answer NO QUESTION - Suggestions concerning this question & answer area

comment test from firefox

2017-09-02 03:08:27 -0600 commented answer NO QUESTION - Suggestions concerning this question & answer area

comment test

2017-09-01 16:49:53 -0600 marked best answer [Q&A] Documentation URL in answers ?

I'm totally agree with @StevenPuttemans and others in OpenCV 3.0 doxygen documentation still very counter intuitive

In the mean time, which URL for the documentation we have to use while answering ?

Example for cv::circle

old doc url (very nice and persistent)

http://docs.opencv.org/modules/core/doc/drawing_functions.html#circle

automatically redirected to 2.4.11 version (redirection is nice too)

http://docs.opencv.org/2.4.11/modules/core/doc/drawing_functions.html#circle

link to current 3.0.0 Doxygen

http://docs.opencv.org/3.0.0/d6/d6e/group__imgproc__draw.html#gaf10604b069374903dbd0f0488cb43670

current 3.0.0 Sphinx

http://docs.opencv.org/3.0-last-rst/modules/imgproc/doc/drawing_functions.html#circle

Referring to the example:

  1. Which URL we have to use in answers ? I suppose current master but...
  2. Will anchors like #gaf10604b069374903dbd0f0488cb43670 survive in the future ?
  3. What about future of path /d6/d6e/group__imgproc__draw.html for Drawing Functions ?

In any case I would suggest better URL facing... is this possible with Doxygen ?

2017-08-25 12:32:13 -0600 answered a question help finding memory corruption in code that writes to a cv::Mat

I would build a cv::Mat over existing data than convert to BGR using Mat::convertTo

// build a cv::Mat over existing data
cv::Mat cvMatFloat(resolutionSize.y,resolutionSize.x,CV_32FC3,(void*)floatImage);
// convert to BGR image
cvMatFloat.convertTo(cvMat,CV_8UC3);
2017-08-11 13:36:16 -0600 commented question Destination image size of LinearPolar / LogPolar

I don't think this is an issue . btw I agree that it would be useful to have this as feature. Time ago I developed a version that works as you request. Please follow your issue on github to get the code and updates. Bye

2017-08-03 10:09:12 -0600 commented answer Is OpenCV GigE Vision and GenIcam Compatible

Sure native API gives more and specific options in special case of non compliant or special camera features.

Mostly, native API are written on top of GenICam. It would be great to see the generic programming interface provided by GenICam for all kind of cameras (Eth,USB,Cl,1394,...) available in OpenCV. This would give access to all GenICam compliant cameras without change source code.

I currently working with GenICam interface. It look is not so hard to import it in OpenCV...maybe a couple of volunteer are enough :)

2017-08-03 05:59:49 -0600 commented answer Is OpenCV GigE Vision and GenIcam Compatible

It would be nice to have a GenICam interface in OpenCV like Halcon and other CV libs have. Maybe any GSOC can be started on this focus in the future.

2017-07-31 12:13:35 -0600 commented question Fail to divide circle into 8 equal parts

you need to detect a pizza and draw 8 slices or detect slices in a pizza ? in both cases please provide your code. and remember... cv2.line() can't cut your pizza ;-)

2017-07-31 11:57:35 -0600 commented answer Fill a vector<vector<Mat>>

ok, user says matrix will change in a for loop maybe his dest *= 2 is just a test. What in case of dest is a video frame or something else ?

2017-07-31 11:46:42 -0600 commented question Fill a vector<vector<Mat>>

as berak has well explained your problem is shallow copy. Here I would just suggest a different method to declare your matrix. You might avoid push_back which causes an automatic reallocation of the allocated storage space. When it's possible I prefer to construct a container with N x M elements like below:

int rows = 2; int cols = 3; 
vector<vector <Mat>> B(rows, vector<Mat>(cols)); //rows x cols matrix of cv::Mat
Mat dest = Mat::ones(10, 10, CV_64F);
for (int r = 0; r<rows; r++)
    for (int c = 0; c < cols; c++) {
        dest *= 2;
        dest.copyTo(B[r][c]);
    }
2017-07-31 11:27:43 -0600 commented answer Fill a vector<vector<Mat>>

@berak To underline side effect of shallow copy It's never enough Tank you !

But, are you sure 2nd option is less expensive ? The point here is that new data must be allocated and assigned for each Mat in B. This is the expensive part which happens either with clone or within temp result. In addiction creating new mat header for the temp result introduces useless overhead.

For sure using clone or copyTo is much more clean and general solution.

2017-07-31 10:47:24 -0600 commented question minMaxLoc() always returns values even template doesn't exist in image

@StevenPuttemans you are so perfect that I was thinking I lost something :-)

2017-07-30 02:42:17 -0600 commented answer How to capture Video from Firewire Basler scout Camera?
2017-07-30 02:12:22 -0600 commented question minMaxLoc() always returns values even template doesn't exist in image

@StevenPuttemans I'm not so sure. _NORMED versions normalize result respect to lightness and template size. This is completely different from range normalization such as normalize() that for sure screw up matches. I'm wrong ?

2017-07-26 05:54:54 -0600 commented answer Logo detection techniques

... but template matching isn't rotation/scale invariant and works bad in case of partial occurrences

2017-07-26 05:47:49 -0600 commented answer Way to filter out False Positives in Template Matching

yeah, algorithm can be powerful but sometimes right environment settings can improve reliability and reduce complexity.... at the end vision starts with light path :)

2017-07-25 09:48:35 -0600 commented answer Way to filter out False Positives in Template Matching

Template matching is not so good in case of occlusion but ....you really can't take picture with (almost) frontal camera and frontal light/diffuse light/2 or 4 lights from different directions? If you can't, you might try perspective correction (since your working plane is static) even if this can't solve screw occlusion.

You might also use 2 camera from opposite direction to catch screw from both sides. I think you should try to control the environment (lights and cam position)

2017-07-25 06:16:18 -0600 answered a question Way to filter out False Positives in Template Matching

1st: It looks you do not clear the score around your match before to locate next match.

This is needed because around the highest match you have a lot of quasi max matches due to small translation of the template around best location. For example your 1st match is 0.9, your 2nd best match has score 0.8 but around your 1st match you might have scores like 0.85 that would produces false match. That's why you have to ignore all scores around a match within an area same as your template.

You can achieve this drawing a filled rectangle in the score images, centred in the location match, using a "color value" lower out of your threshold (the tutorial should be updated with this).

2nd: Using half or quarter screw is too simple template this would produces a lot of false matches. I suggest to use full screw with a bit of frame around as template. If the screw is '+' type than you can use 2 templates 45deg rotated. But because the screw looks "torks" type you might forget about rotation.

2017-07-24 09:16:36 -0600 commented question Way to filter out False Positives in Template Matching

How do you perform template match (method) ? Has your template same size/rotation of finding ? How do you perform multiple matching filtering (do you clean scores around) ?

read this is-template-matching-the-best-approach-to-go-about-when-finding-the-exact-image-on-the-screen-multiple-times, Template Matching is wrong with specific Reference image

2017-07-12 03:03:59 -0600 commented answer Is template matching the best approach to go about when finding the "Exact" image on the screen multiple times?

If exact match means Template~=Image(ROI) then TM_CCOEFF/TM_CCORR is waste time and resources because of much complex calculations they requires.

If exact match means exact location of the template, each method provides the best location. But if Template~Image(ROI), location is not perfect due to image differences. In this cases TM_CCOEFF/TM_CCORR offer better robustness.

Finally for multiple match you have clean scores around current match. Read: set scores to a value out of your bias. With TM_SQDIFF use any value higher than your bias. For TM_CCOEFF/TM_CCORR use any value lower.

NORMED versions provide output in a fixed range -1..0..1. See my answers here http://answers.opencv.org/question/51486 and http://answers.opencv.org/question/63587

2017-07-10 04:59:48 -0600 commented answer Is template matching the best approach to go about when finding the "Exact" image on the screen multiple times?

I think you are able to swithc from Rect/Size pt1/pt2 please check UPDATE3 also for right cleaner value

2017-07-09 11:24:29 -0600 edited answer Is template matching the best approach to go about when finding the "Exact" image on the screen multiple times?

if template is present in the image at point P(x,y), templateMatching returns P(x+epsilon,y+epsilon) where epsilon might be 0 or very small if the match is similar. Exact match will returns exact position.

BTW if "exact" means T-I=0 you can use a simple slider difference like below

int ExactMatch(const Mat& I, const Mat &T, std::vector<Point> &matches)
{
    //Mat I; // the image
    //Mat T; // the template
    //std::vector<Point> matches; // vector of exact match point

    //works only on grayscale image because to minMaxLoc
    cvAssert((I.channels()==1)   && (T.channels()==1))
    matches.clear();
    Rect R(Point(0, 0), T.size()); //a rect roi over the image
    Mat delta;
    int nx = I.cols - T.cols;   // numbers of horiz sliding ROI
    int ny = I.rows - T.rows;   // numbers of vert sliding ROI
    double maxValue;
    Point maxLoc,match;
    for (int x = 0; x < nx; x++)
        for (int y = 0; y < ny; y++)
        {
            R.x = x; R.y = y;
            absdiff(T, I(R), delta);  //delta = |T - I(R) |
            // search for max in the difference
            minMaxLoc(delta, NULL, &maxValue, NULL, &maxLoc);
            //max==0 means delta == 0 means exact match
            if (maxValue == 0)
            {
                match = Point(x, y);
                cout << "Exact found at " << match << endl;
                matches.push_back(match);
            }
        }
    return (int)matches.size();
}

UPDATE:

Despite of above code works (on 1channel images) it is really inefficient. The way templateMatch/CV_TM_SQDIFF is much faster and general.

UPDATE2: This should works on Java: UPDATE3: small fix (please be tolerant to syntax error. I don't have a java machine)

Mat resultMatrix = new Mat();
int result_cols =  source.cols() - template.cols() + 1;
int result_rows = source.rows() - template.rows() + 1;
resultMatrix.create( result_rows, result_cols, CvType.CV_32FC1 );
Imgproc.matchTemplate(source, template, resultMatrix, Imgproc.TM_SQDIFF_NORMED);

epsilon = 0.1; // increase to be more tolerant
while (true)
{
    MinMaxLocResult mmr = Core.minMaxLoc(resultMatrix);
    if (mmr.minVal > epsilon )
            break; // no more matches

    Point matchLoc = mmr.minLoc;
    System.out.print("\nMatch found at: "); System.out.print(matchLoc);
    System.out.print("\tDifference: "); System.out.print(mmr.minVal);
    // clean scores around current match
    Imgproc.rectangle(resultMatrix,
        // clean around center
        new Point(matchLoc.x - template.cols()/2, matchLoc.y - template.rows()/2),
        new Point(matchLoc.x + template.cols()/2, matchLoc.y + template.rows()/2),
        // set to a value greater than your threshold
        new Scalar(epsilon+1, epsilon+1, epsilon+1), -1);
    // draw a rectangle around match
    Imgproc.rectangle(source, 
        matchLoc,
        new Point(matchLoc.x + template.cols(), matchLoc.y + template.rows()),
        new Scalar(0, 255, 0), 1);
}
2017-07-09 11:04:35 -0600 commented answer Is template matching the best approach to go about when finding the "Exact" image on the screen multiple times?

@jas

  1. cv::threshold must not be used here because you cut all matching scores!
  2. Iterate while minValue<epsilon where epsilon is a small value
  3. For each iteration cut scores around match...BUT the matching point must be at centre of your cleaner rectangle.

Check UPDATE2 in my answer