-
Notifications
You must be signed in to change notification settings - Fork 157
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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,
- Can you please format everything with clang-format.
- It is useful to have a descriptive summary of what the function intends to do on top of its definition/declaration.
- 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) |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Draft PR for opencv test integration #115