1 | initial version |
Much more optimization could be done, but at least this is working:
void add_piece_of_frame(const Mat &A, Mat &B, int r, int c)
{
Rect Roi(r, c, 40, 40);
A.copyTo(B(Roi));
}
void add_piece_of_frame_red(const Mat &A, Mat &B, int r, int c)
{
Rect Roi(r, c, 40, 40);
Scalar color = Scalar(0, 0, 255);
Mat mask = Mat(40, 40, CV_8UC3, color);
addWeighted(A, 0.5, mask, 0.5, 0, B(Roi), CV_8UC3);
}
void main()
{
Mat bkg_read = imread("C:\\Users\\Fabrizio\\Desktop\\frame\\VIDEO_PER_TESI\\Scene1.jpg", CV_LOAD_IMAGE_COLOR);
imshow("original", bkg_read);
waitKey(1);
Mat ricostruzione[48];
int aa[48];
int bb[48];
int m = 0;
for (int a = 0; a<320; a += 40)
{
for (int b = 0; b<240; b += 40)
{
Mat SUPPORT(bkg_read, Rect(a, b, 40, 40));
ricostruzione[m] = SUPPORT.clone();
aa[m] = a;
bb[m] = b;
cout << "coordinate: " << endl;
cout << "a: " << aa[m];
cout << "\tb: " << bb[m] << endl;
m++;
}
}
while (true) //what is this loop for???
{
Mat output = cv::Mat::zeros(240, 320, CV_8UC3);
Mat output_red = cv::Mat::zeros(240, 320, CV_8UC3);
for (int t = 0; t<48; t++)
{
add_piece_of_frame_red(ricostruzione[t], output_red, aa[t], bb[t]);
}
imshow("output_red", output_red);
waitKey(0);
for (int u = 0; u<48; u++)
{
add_piece_of_frame(ricostruzione[u], output, aa[u], bb[u]);
}
imshow("output", output);
waitKey(0);
}
}
2 | No.2 Revision |
Much more optimization could be done, but at least this is working:working, if that is all you want:
void add_piece_of_frame(const Mat &A, Mat &B, int r, int c)
{
Rect Roi(r, c, 40, 40);
A.copyTo(B(Roi));
}
void add_piece_of_frame_red(const Mat &A, Mat &B, int r, int c)
{
Rect Roi(r, c, 40, 40);
Scalar color = Scalar(0, 0, 255);
Mat mask = Mat(40, 40, CV_8UC3, color);
addWeighted(A, 0.5, mask, 0.5, 0, B(Roi), CV_8UC3);
}
void main()
{
Mat bkg_read = imread("C:\\Users\\Fabrizio\\Desktop\\frame\\VIDEO_PER_TESI\\Scene1.jpg", CV_LOAD_IMAGE_COLOR);
imshow("original", bkg_read);
waitKey(1);
Mat ricostruzione[48];
int aa[48];
int bb[48];
int m = 0;
for (int a = 0; a<320; a += 40)
{
for (int b = 0; b<240; b += 40)
{
Mat SUPPORT(bkg_read, Rect(a, b, 40, 40));
ricostruzione[m] = SUPPORT.clone();
aa[m] = a;
bb[m] = b;
cout << "coordinate: " << endl;
cout << "a: " << aa[m];
cout << "\tb: " << bb[m] << endl;
m++;
}
}
while (true) //what is this loop for???
{
Mat output = cv::Mat::zeros(240, 320, CV_8UC3);
Mat output_red = cv::Mat::zeros(240, 320, CV_8UC3);
for (int t = 0; t<48; t++)
{
add_piece_of_frame_red(ricostruzione[t], output_red, aa[t], bb[t]);
}
imshow("output_red", output_red);
waitKey(0);
for (int u = 0; u<48; u++)
{
add_piece_of_frame(ricostruzione[u], output, aa[u], bb[u]);
}
imshow("output", output);
waitKey(0);
}
}