-
Notifications
You must be signed in to change notification settings - Fork 0
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
Suvorov DM/accuracy verification #115
Changes from 3 commits
8058ccd
9889f93
8ab8f91
fe2a880
9fa2191
e4e2a46
98e4d38
9bc2fc2
e604520
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include <opencv2/opencv.hpp> | ||
#include <iostream> | ||
#include <filesystem> | ||
|
||
int main() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please create help message for users |
||
std::string directory = "./photos"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accept directory as cmd line argument |
||
|
||
for (const auto& entry : std::filesystem::directory_iterator(directory)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I suggest using this, it is a common widely-used way to simplify std::filesystem related code |
||
if (entry.is_regular_file()) { | ||
cv::Mat image = cv::imread(entry.path().string()); | ||
|
||
// For example: | ||
if (!image.empty()) { | ||
cv::imshow("Image", image); | ||
cv::waitKey(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will show the images in a sequential order and block the execution. It is better not to do this. Our future application will not do that, actually. What you need to do at this stage: read the content of the image, convert to tensor (cv::Mat -> Tensor, use our tensor class) and do nothing with this tensor (for now) |
||
} else { | ||
std::cerr << "Read image error. Image path is: " << entry.path() << std::endl; | ||
} | ||
} | ||
} | ||
|
||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,17 @@ std::ostream& operator<<(std::ostream& out, const Tensor& t) { | |
} | ||
return out; | ||
} | ||
|
||
template <typename T> | ||
bool elementwiseTensorCmp(const Tensor& t1, const Tensor& t2, double threshold) { | ||
if (t1.get_shape().count() != t2.get_shape().count()) return false; | ||
if (t1.get_type() != t2.get_type()) return false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd rather throw an error in this case, cause it is just invalid, not meaning that these tensors are not equal |
||
|
||
size_t size = t1.get_shape().count(); | ||
for (size_t i = 0; i < size; i++) { | ||
if (std::abs(*(t1.as<T>())[i] - *(t2.as<T>())[i]) > threshold) { | ||
return false; | ||
} | ||
} | ||
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.
warning: 'opencv2/opencv.hpp' file not found [clang-diagnostic-error]