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

opencv test draft for ImageContainer #303

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

markram1729
Copy link

Draft PR for opencv test integration #115

@markram1729 markram1729 marked this pull request as ready for review May 15, 2024 04:49
Copy link
Member

@meshtag meshtag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work!

I have added some high level comments.
Additionally,

  1. Can you please format everything with clang-format.
  2. It is useful to have a descriptive summary of what the function intends to do on top of its definition/declaration.
  3. It is a good idea to separate logically different lines of code with a newline for better readability.

return false;
}
template<typename T,size_t N>
bool testcvdp(cv::Mat testImgcv,Img<T,N> testImg,bool norm = false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a more descriptive name here?

{
if(!norm)
{
if(!compare_flt(data[k],(T)testImgcv.at<uchar>(i,j))) return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to explicitly return false here, just return the function result directly.

}
else
{
if(!compare_flt(data[k],(T)testImgcv.at<T>(i,j)))return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both of these branches (if and else block) can be simplified using a ternary operator.

T *data= testImg.getData();
if(N==2)
{
int k=0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really require signedness from the variable here? You can use unsigned in all cases where it is not required.

{
if(a==b) return true;
float eps = a-b;
if(eps<0)eps=-eps;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use std::abs to eliminate an unnecessary branch here.

if(a==b) return true;
float eps = a-b;
if(eps<0)eps=-eps;
if(eps<FLT_EPSILON) return true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for explicit true and false here, you can just return the comparison result itself.

@markram1729 markram1729 requested a review from meshtag May 28, 2024 12:40
Copy link
Member

@meshtag meshtag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good. I have added few more comments.

tests/Interface/core/ImageContainerTest.cpp Outdated Show resolved Hide resolved
tests/Interface/core/ImageContainerTest.cpp Outdated Show resolved Hide resolved
tests/Interface/core/ImageContainerTest.cpp Outdated Show resolved Hide resolved
tests/Interface/core/ImageContainerTest.cpp Outdated Show resolved Hide resolved
tests/Interface/core/ImageContainerTest.cpp Outdated Show resolved Hide resolved
tests/Interface/core/ImageContainerTest.cpp Outdated Show resolved Hide resolved
tests/Interface/core/ImageContainerTest.cpp Show resolved Hide resolved
@markram1729 markram1729 requested a review from meshtag June 26, 2024 04:30
@markram1729 markram1729 marked this pull request as draft July 1, 2024 04:22
@markram1729 markram1729 marked this pull request as ready for review July 1, 2024 04:23
@markram1729 markram1729 marked this pull request as draft August 3, 2024 08:52
@markram1729 markram1729 marked this pull request as ready for review August 3, 2024 08:53
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.

None yet

2 participants