Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BoxPoints, MinAreaRect inconsistent with C++ version of OpenCV, causing precision issues #1152

Closed
TeCHiScy opened this issue Feb 27, 2024 · 2 comments

Comments

@TeCHiScy
Copy link
Contributor

Description

In the gocv impl, for example, the MinAreaRect function (https://github.com/covrom/gocv/blob/master/imgproc.cpp#L185), rounds points coordination, center point coordination, and size of a RotatedRect to int, while in OpenCV, they are float. I'm porting Paddle inference code from C++ to Go (which needs gocv), where keeping float precision is essential in sequence of operations, otherwise errors may accumulate. So here's my question:

  • Is the round used in BoxPoints and MinAreaRect intentionally (by design)?
  • If not, would you accept a PR that provides float precision version, e.g. BoxPoints2f, MinAreaRect2f that consistents with OpenCV?

Steps to Reproduce

No steps needed.

Your Environment

  • Operating System and version: Linux docker-desktop 6.6.12-linuxkit # 1 SMP Fri Jan 19 08:53:17 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
  • OpenCV version used: 4.8.1
  • How did you install OpenCV? GoCV Makefile
  • GoCV version used: v0.35.0
  • Go version: go version go1.21.7 linux/amd64
  • Did you run the env.sh or env.cmd script before trying to go run or go build? Not related
@deadprogram
Copy link
Member

Hello @TeCHiScy

would you accept a PR that provides float precision version, e.g. BoxPoints2f, MinAreaRect2f that consistents with OpenCV?

Yes, please.

The reason for the rounding in BoxPoints() and MinAreaRect() is because most people expect to be able to do something with that Rect such as display it. So your use case is a little different, but seems like a good thing.

@TeCHiScy
Copy link
Contributor Author

TeCHiScy commented Apr 8, 2024

Close as completed in v0.36.0.

@TeCHiScy TeCHiScy closed this as completed Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants