Ask Your Question

Björn Larsson's profile - activity

2021-07-05 07:41:58 -0500 received badge  Popular Question (source)
2018-10-03 16:23:03 -0500 received badge  Teacher (source)
2018-05-03 12:08:05 -0500 received badge  Necromancer (source)
2018-05-03 05:41:51 -0500 edited answer Check if a Point is inside a RotatedRect ?

A rotated rectangle consists of four points, the corners. Therefore it should be possible to convert it to a contour. Th

2018-05-03 05:36:17 -0500 commented answer Check if a Point is inside a RotatedRect ?

Keep in mind that indicator == 0 when the point is on the rectangle edge.

2018-05-03 05:33:39 -0500 answered a question Check if a Point is inside a RotatedRect ?

A rotated rectangle consists of four points, the corners. Therefore it should be possible to convert it to a contour. Th

2018-03-22 05:10:05 -0500 received badge  Enthusiast
2018-03-08 08:19:36 -0500 marked best answer copyMakeBorder returns un-solid border

Goal: Adding a solid white line to a black'n'white image.

I'm trying to extract text from an image by cropping it and then adding a solid border with copyMakeBorder(). My problem is that I can't make the border solid. It seems like the copyMakeBorder() uses information from my initial image instead.

This is my code:

void OcvCardReader::cropToAreaWithSolidBorder(Mat image, const Rect2f area) {
    //Crop the image.
    image = image(area);
    //Add the border.
    int borderSize = 10;
    copyMakeBorder(image, image,
        borderSize, borderSize, borderSize, borderSize,
        BORDER_CONSTANT, Scalar(255));
}

My input image looks like this: Input image

This is after the crop: Cropped image

And finally, after adding the border: image description

Note the black pixels att the bottom left. I had expected a border to be white all around. I also tried to use Scalar(0) to see if it makes any difference. It doesn't.

Curiously, it works well if I convert the image to a 3-channel Mat and then use Scalar(255, 255, 255), but that seems like a detour to me.

So, why does copyMakeBorder() return a border that isn't solid?

2018-03-07 10:38:17 -0500 received badge  Self-Learner (source)
2018-03-07 09:51:13 -0500 edited answer copyMakeBorder returns un-solid border

So, I've tried a few different solutions based on the comments I got. First I tried to change the call to call by refer

2018-03-07 09:49:36 -0500 answered a question copyMakeBorder returns un-solid border

So, I've tried a few different solutions based on the comments I got. First I tried to change the call to call by refer

2018-03-07 03:31:32 -0500 edited question copyMakeBorder returns un-solid border

copyMakeBorder returns un-solid border Goal: Adding a solid white line to a black'n'white image. I'm trying to extract

2018-03-06 03:08:20 -0500 commented question copyMakeBorder returns un-solid border

Oh! I thought a Mat was big enough to be passed by reference automagically. Thanks! I will try that! :-D

2018-03-05 09:43:27 -0500 asked a question copyMakeBorder returns un-solid border

copyMakeBorder returns un-solid border Goal: Adding a solid white line to a black'n'white image. I'm trying to extract

2018-03-02 13:12:46 -0500 received badge  Student (source)
2018-03-02 09:57:10 -0500 commented answer Minimal area rectangle for multiple contours

Thanks, that solved my problem! :-)

2018-03-02 09:56:58 -0500 commented answer Minimal area rectangle for multiple contours

Thanks, that solved my problem!

2018-03-02 09:56:50 -0500 received badge  Supporter (source)
2018-03-02 09:55:48 -0500 commented answer Minimal area rectangle for multiple contours

Thanks, that solved my problem! Unfortunately, I can't up-vote your answer due to low karma, even though you deserve it.

2018-03-02 09:53:56 -0500 marked best answer Minimal area rectangle for multiple contours

I have a case with several contours

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

I want to get the smallest area rectangle RotatedRect containing all these contours. I have tried minAreaRect() but it returns an exception (probably because I pass it more than one contour).

What would be the best way of getting the minimal area rectangle when you're dealing with more than one contour?

2018-03-02 09:53:56 -0500 received badge  Scholar (source)
2018-03-02 05:09:20 -0500 edited question Minimal area rectangle for multiple contours

Minimal area rectangle for multiple contours I have a case with several contours std::vector<std::vector<cv::Poin

2018-03-02 05:08:26 -0500 commented question Minimal area rectangle for multiple contours

A rotated rectangle, but bonus points if the answer includes bounding box as well! :-)

2018-03-02 05:07:52 -0500 received badge  Editor (source)
2018-03-02 05:07:52 -0500 edited question Minimal area rectangle for multiple contours

Minimal area rectangle for multiple contours I have a case with several contours std::vector<std::vector<cv::Poin

2018-03-02 05:07:10 -0500 commented question Minimal area rectangle for multiple contours

A rotated rectangle.

2018-03-02 05:06:41 -0500 commented question Minimal area rectangle for multiple contours

A rotated rectangle.

2018-03-02 04:48:50 -0500 asked a question Minimal area rectangle for multiple contours

Minimal area rectangle for multiple contours I have a case with several contours std::vector<std::vector<cv::Poin