Skip to content

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 61 additions & 3 deletions src/zmq/zmq-source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

Why not just void?

Copy link
Member

Choose a reason for hiding this comment

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

First parameter may be const.

{
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)
Copy link
Member

Choose a reason for hiding this comment

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

First two parameters may be const.

{
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();
Copy link
Member

Choose a reason for hiding this comment

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

Explicit release again is redundant.

reduction_matrix.copyTo(frame_open_CV);
}

/* ***************************************************** */
Expand Down