-
Notifications
You must be signed in to change notification settings - Fork 1
Update main.cpp #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -277,10 +277,68 @@ int worker_stub(const config_t & cfg) | |
return 0; | ||
} | ||
|
||
// stub image processing | ||
void process_image(cv::Mat & in_out) | ||
//finding boundaries | ||
int border_image(cv::Mat& frame_open_CV, cv::Mat& detected_edges) | ||
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. First parameter may be |
||
{ | ||
cv::GaussianBlur(in_out, in_out, { 51, 51 }, 0); | ||
int lowThreshold = 200; | ||
int ratio = 10; | ||
int kernel_size = 5; | ||
cv::Mat frame_open_CV_gray, dst; | ||
dst.create(frame_open_CV.size(), frame_open_CV.type()); | ||
cv::cvtColor(frame_open_CV, frame_open_CV_gray, cv::COLOR_BGR2GRAY); | ||
cv::blur(frame_open_CV_gray, detected_edges, cv::Size(kernel_size, kernel_size)); | ||
cv::Canny(detected_edges, detected_edges, lowThreshold, lowThreshold * ratio, kernel_size); | ||
dst = cv::Scalar::all(0); | ||
frame_open_CV.copyTo(dst, detected_edges); | ||
return 0; | ||
} | ||
|
||
//reduction and merge | ||
int reduction_plus_merge_image(cv::Mat& frame_open_CV, cv::Mat& detected_edges, cv::Mat& reduction_matrix) | ||
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. First two parameters may be |
||
{ | ||
cv::Mat channels_frame_open_CV[3], channels_detected_edges[3]; | ||
int frame_CV_width = frame_open_CV.size().width; | ||
int frame_CV_height = frame_open_CV.size().height; | ||
cv::split(frame_open_CV, channels_frame_open_CV); | ||
cv::split(detected_edges, channels_detected_edges); | ||
int max_z = 256; | ||
int step_z = 64; | ||
for (int i = 0; i < frame_CV_height; i++) | ||
{ | ||
for (int j = 0; j < frame_CV_width; j++) | ||
{ | ||
for (uchar z = 0; z < max_z - step_z; z += step_z) | ||
{ | ||
for (int t = 0; t < 3; t++) | ||
{ | ||
if (channels_frame_open_CV[t].data[i * frame_CV_width + j] > z&& | ||
channels_frame_open_CV[t].data[i * frame_CV_width + j] < z + step_z) | ||
{ | ||
channels_frame_open_CV[t].data[i * frame_CV_width + j] = z + step_z / 2; | ||
} | ||
} | ||
if (channels_detected_edges[0].data[i * frame_CV_width + j] == 255) | ||
{ | ||
|
||
channels_frame_open_CV[0].data[i * frame_CV_width + j] = 0; | ||
channels_frame_open_CV[1].data[i * frame_CV_width + j] = 0; | ||
channels_frame_open_CV[2].data[i * frame_CV_width + j] = 255; | ||
} | ||
} | ||
} | ||
} | ||
cv::merge(channels_frame_open_CV, 3, reduction_matrix); | ||
return 0; | ||
} | ||
|
||
//image processing | ||
void process_image(cv::Mat& frame_open_CV) | ||
{ | ||
cv::Mat detected_edges, reduction_matrix; | ||
border_image(frame_open_CV, detected_edges); | ||
reduction_plus_merge_image(frame_open_CV, detected_edges, reduction_matrix); | ||
frame_open_CV.release(); | ||
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. Explicit release again is redundant. |
||
reduction_matrix.copyTo(frame_open_CV); | ||
} | ||
|
||
/* ***************************************************** */ | ||
|
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.
Why not just void?