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

Correct TypeScript signature for minEnclosingCircle to match opencv.js single parameter #57

Merged
merged 2 commits into from
Mar 17, 2024

Conversation

th-alexmak
Copy link
Contributor

This pull request corrects the TypeScript definition of the minEnclosingCircle function to align with the opencv.js implementation, which accepts only a single parameter. The existing type definitions mistakenly required three parameters to be passed to this function, which conflicted with the actual opencv.js API and led to compile-time errors in TypeScript projects.

The erroneous type signature forced TypeScript developers to call minEnclosingCircle incorrectly with three arguments or to suppress type checking with a @ts-ignore comment, neither of which is an ideal solution.

To address this issue, I have updated the function signature in the TypeScript definitions to accept only one parameter, as per the opencv.js documentation. Additionally, I have introduced a new Circle class definition that encapsulates the return type of minEnclosingCircle, providing a structured object that contains both the center point and radius of the circle.

The Circle class enhances type safety and developer experience by offering clear insights into the expected return object structure, which includes:

  • center: The center point of the enclosing circle.
  • radius: The radius of the enclosing circle.

By merging this pull request, we will ensure that the TypeScript definitions correctly represent the opencv.js library's API, thus preventing any confusion and errors when developers invoke minEnclosingCircle. This change will also promote better code quality and maintainability in TypeScript projects leveraging opencv.js.

This class is used for `minEnclosingCircle` method as a return value.
The `minEnclosingCircle` in opencv.js does not accept 3 parameters. Instead, it accepts points only and return the enclosing circle like python, which is an object that has `center` and `radius`.
@ttt43ttt ttt43ttt merged commit 0a09ffd into TechStark:main Mar 17, 2024
@ttt43ttt
Copy link
Contributor

@th-alexmak thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants