Ask Your Question

Pedro Batista's profile - activity

2020-10-04 11:51:39 -0600 marked best answer Calculating sum using integral image

I am attempting to calculate sums over rectangular areas in images using the Viola & Jones trick with the integral image.

Im using c++ and the cv::Mat class.

Here is what I am doing:

.
.
.


    integral(Img,M);

    CvRect region;

    region.x=0; 
    region.y=0; 
    region.width=Img.cols;
    region.height=Img.rows; //calculating sum on entire image


      double regionSum;

      int tl= IntegralImage.at<double>((region.y),(region.x));
      int tr= IntegralImage.at<double>((region.y),(region.x+region.width+1));
      int bl= IntegralImage.at<double>((region.y+region.height+1),(region.x));
      int br= IntegralImage.at<double>((region.y+region.height+1),(region.x+region.width+1));

      regionSum = br-bl-tr+tl;

      cout<<"tl: "<<tl<<" tr: "<<tr<<" bl: "<<bl<<" br: "<<br<<" sum: "<<regionSum<<endl;

For some images those parameters output zero, for others there is a result but that doesn't really make sense, so obviously I am doing something wrong-

Thanks in advance.

2020-07-20 04:49:00 -0600 received badge  Notable Question (source)
2019-01-25 12:43:33 -0600 marked best answer Grouping different scale bounding boxes

I've created an openCV application for human detection on images.

I run my algorithm on the same image over different scales, and when detections are made, at the end I have information about the bounding box position and at which scale it was taken from. Then I want to transform that rectangle to the original scale, given that position and size will vary.

I've wrapped my head around this and I've gotten nowhere. This should be rather simple, but at the moment I am clueless.

Help anyone?

2019-01-22 05:05:17 -0600 commented answer How to delete additional circles in OpenCV's Finger Detection?

This method will work with multiple hands in the same image if each one is a contour on its own. Once you detect fingert

2019-01-21 21:23:59 -0600 received badge  Nice Answer (source)
2019-01-17 09:58:52 -0600 commented question Image Classification

@Raki, if you end up trying Steven's suggestion I would be curious to know the results!

2019-01-17 08:53:24 -0600 commented answer How to delete additional circles in OpenCV's Finger Detection?

I gave you the direction and now it is your job to do the work. Use cv2.findContours() to calculate the countour coordin

2019-01-17 06:58:51 -0600 edited answer How to delete additional circles in OpenCV's Finger Detection?

Maybe try taking a different aproach, try to compute all distances between the hand centroid and each point in the conto

2019-01-17 06:57:54 -0600 edited answer How to delete additional circles in OpenCV's Finger Detection?

Maybe try taking a different aproach, try to compute all distances between the hand centroid and each point in the conto

2019-01-17 06:49:39 -0600 edited answer How to delete additional circles in OpenCV's Finger Detection?

Maybe try taking a different aproach, try to compute all distances between the hand centroid and each point in the conto

2019-01-17 06:45:46 -0600 edited answer How to delete additional circles in OpenCV's Finger Detection?

Maybe try taking a different aproach, try to compute all distances between the hand centroid and each point in the conto

2019-01-17 06:44:47 -0600 edited answer How to delete additional circles in OpenCV's Finger Detection?

Maybe try taking a different aproach, try to compute all distances between the hand centroid and each point in the conto

2019-01-17 06:38:26 -0600 edited answer How to delete additional circles in OpenCV's Finger Detection?

Maybe try taking a different aproach, try to compute all distances between the hand centroid and each point in the conto

2019-01-17 06:38:13 -0600 edited answer How to delete additional circles in OpenCV's Finger Detection?

Maybe try taking a different aproach, try to compute all distances between the hand centroid and each point in the conto

2019-01-17 06:29:53 -0600 answered a question How to delete additional circles in OpenCV's Finger Detection?

Maybe try taking a different aproach, try to compute all distances between the hand centroid and each point in the conto

2018-08-07 10:31:10 -0600 edited answer CNN / DNN Usage question.

CNNs are trully remarkable. It is an established fact that they are solving problems that years of previous academic and

2018-08-07 07:34:56 -0600 commented answer CNN / DNN Usage question.

I realize that I may sound like a guy that is not able to adapt to a change in the field, but that is not the case. I us

2018-08-07 07:33:07 -0600 commented answer CNN / DNN Usage question.

I realize that I sound like a guy that is not able to adapt to a change in the field, but that is not the case. I use wh

2018-08-07 06:17:51 -0600 answered a question CNN / DNN Usage question.

CNNs are trully remarkable. It is an established fact that they are solving problems that years of previous academic and

2018-06-05 12:13:27 -0600 commented question How to read VideoCapture as parts in multiple threads

It will increase if your video is so small that the splitting function would become the bottleneck, which would make you

2018-06-05 12:11:50 -0600 commented question How to read VideoCapture as parts in multiple threads

It will increase if your video is so small that the splitting function would become the bottleneck, in which case making

2018-06-05 09:55:39 -0600 commented question How to read VideoCapture as parts in multiple threads

Why don't you split your video into multiple files in a preprocessing function, and then create an array of VideoCapture

2018-04-23 11:19:28 -0600 commented question How do is split this binary image blob, with no particular shape?

I've had and solved this particular problem. Here is a description of what I did. Unfortunately the links to the images

2018-03-23 18:35:27 -0600 received badge  Famous Question (source)
2018-03-02 05:02:02 -0600 commented question Minimal area rectangle for multiple contours

You want a rotated rectangle containing all the contours in the vector, our just a bounding box enclosing all the contou

2018-03-01 04:54:03 -0600 received badge  Nice Answer (source)
2018-03-01 04:50:48 -0600 edited answer Writing filestream with python?

It seems that versions prior to 3.1.0 do not have all FileStorage functionality implemented. After version 3.2.0 this

2018-03-01 04:45:34 -0600 edited answer Writing filestream with python?

It seems that versions prior to 3.0.0 do not have all FileStorage functionality implemented. After version 3.2.0 this

2018-02-19 09:42:23 -0600 commented question Get strength of edges using magnitude

I don't think opencv has a standard way to calculate the magnitude of a given line, so, if you have the coordinates of e

2018-01-10 11:08:16 -0600 received badge  Nice Answer (source)
2018-01-10 05:17:50 -0600 edited answer Applying contours on an image

An example image would help to give a more definitive answer, but yes, you can probably automate this process using Open

2018-01-10 05:16:30 -0600 edited answer Applying contours on an image

An example image would help to give a more definitive answer, but yes, you can probably automate this process using Open

2018-01-10 05:15:51 -0600 edited answer Applying contours on an image

An example image would help to give a more definitive answer, but yes, you can probably automate this process using Open

2018-01-10 05:14:47 -0600 edited answer Applying contours on an image

An example image would help to give a more definitive answer, but yes, you can probably automate this process using Open

2018-01-10 05:14:21 -0600 edited answer Applying contours on an image

An example image would help to give a more definitive answer, but yes, you can probably automate this process using Open

2018-01-10 05:14:06 -0600 edited answer Applying contours on an image

An example image would help to give a more definitive answer, but yes, you can probably automate this process using Open

2018-01-10 05:12:31 -0600 edited answer Applying contours on an image

An example image would help to give a more definitive answer, but yes, you can probably automate this process using Open

2018-01-10 05:11:06 -0600 answered a question Applying contours on an image

An image would help to give a more definitive answer, but yes, you can probably automate this process using OpenCV, but

2018-01-10 04:52:53 -0600 commented question Applying contours on an image

I accidentelly misclicked into deleting a comment from this thread, sorry to the autor, please repost the comment.

2017-12-21 09:30:00 -0600 commented answer Writing filestream with python?

If you have a problem, post a question with code :) That information is not enough to know what is wrong.

2017-12-21 07:30:50 -0600 commented answer Writing filestream with python?

What opencv version are you using? I found out that only after 3.2.0 this was implemented in Python.

2017-12-20 11:25:12 -0600 edited answer Building contours from points

OpenCV expects a contour to be a list of points of connected pixels, in which the starting point is the top-most one (wi

2017-12-20 11:19:13 -0600 answered a question Building contours from points

OpenCV expects a contour to be a list of points of connected pixels, in which the starting point is the top-most one (wi

2017-11-11 15:37:24 -0600 received badge  Nice Question (source)
2017-09-29 11:17:35 -0600 answered a question Dynamic gesture recognition

Generally plase give me some suggestions what is you impression about such a system. Depends on a lot of things.

2017-09-29 06:39:02 -0600 answered a question in HOG, what if search window stride is smaller than cell size?

It makes sense that reducing the sliding window stride will improve the detection accuracy, because a smaller stride wil

2017-09-25 04:58:23 -0600 edited question how to detect multiple cars in an image using opencv??

how to detect multiple cars in an image using opencv?? I'm using the following code, but i'm able to detect only one car

2017-08-16 04:58:47 -0600 received badge  Good Answer (source)
2017-08-12 14:20:38 -0600 marked best answer cv::FindContours() spiking CPU usage to the limit

While developing some stuff that uses blob analysis , I realized my application was dropping frames. After evaluating what might be the cause, I singled out the findContours call as the culprit.

I created this small code snippet to understand what was going on,

#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
int main()
{
    while ((char) cv::waitKey(30) != 'q')
    {
        cv::Size size = cv::Size(640, 480);

        cv::Mat testFindContours = cv::Mat::zeros(size, CV_8UC1);

        std::vector<std::vector<cv::Point> > contours;
        std::vector<cv::Vec4i> hierarchyObj;

        cv::findContours(testFindContours, contours, hierarchyObj, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);

        cv::imshow("Black window", testFindContours);
    }

    return 0;
}

Weirdly enough, just by using findContours on a 640x480 completely black image, my CPU spikes to ~300% usage (more than one CPU cores at full speed).

VGA

The number on the most right-hand side is the CPU usage % (from "top" in linux)

Even weirder, is when I reduced the Size to 320x240, now the CPU usage stayes below 2%

QVGA

I started playing a bit with the size, and I have the impression that there is a specific size at which the CPU spikes up to 300%, but I didn't go far enough to check which size that is exactly, so I am not completely sure about this.

What am I missing here? Is it normal that findContours even consumes anything on a completely black image? Might this be a bug?

The CPU I am doing these tests in is a intel core i7 3.4 ghz and opencv version 3.2.0. I'm compiling this code in Debug configuration.

Best regards.