1 | initial version |
CV_16US means signed short this line is wrong
cout << grad_x.at<int>(i, j) << endl;
It should be
cout << grad_x.at<short>(i, j) << endl;
2 | No.2 Revision |
CV_16US CV_16S means signed short this line is wrong, also you got i,j wrong (opencv is row-major)
cout << grad_x.at<int>(i, j) << endl;
It should be
cout << grad_x.at<short>(i, j) grad_x.at<short>(j,i) << endl;
3 | No.3 Revision |
CV_16S means signed short this line is wrong, also you got i,j wrong wrong.
(opencv is row-major)
cout << grad_x.at<int>(i, j) << endl;
It should be
cout << grad_x.at<short>(j,i) << endl;
4 | No.4 Revision |
CV_16S means signed short this line is wrong, also you got i,j wrong.
(opencv is row-major)
cout << grad_x.at<int>(i, j) << endl;
It should be
cout << grad_x.at<short>(j,i) << endl;
I use this program to test ( frame unused) grad_x empty don't need to print....
{
Mat prev_frame=imread("g:/lib/opencv/samples/data/fruits.jpg",IMREAD_GRAYSCALE);
resize(prev_frame, prev_frame, Size(8, 8));
cout << prev_frame << " \n";
Mat grad_x, grad_y;
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
Sobel(prev_frame, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT);
Sobel(prev_frame, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT);
cout << grad_x << endl;
double min, max;
minMaxLoc(grad_x, &min, &max);
cout << min << endl;
cout << max << endl;
for (int i = 0; i < grad_x.cols; i++)
{
for (int j = 0; j < grad_x.rows; j++)
{
cout << grad_x.at<short>(j, i)<<"\t" ;
}
cout << endl;
}
}
5 | No.5 Revision |
CV_16S means signed short this line is wrong, also you got i,j wrong.
(opencv is row-major)
cout << grad_x.at<int>(i, j) << endl;
It should be
cout << grad_x.at<short>(j,i) << endl;
I use this program to test ( frame unused) grad_x empty don't need to print....
{
Mat prev_frame=imread("g:/lib/opencv/samples/data/fruits.jpg",IMREAD_GRAYSCALE);
resize(prev_frame, prev_frame, Size(8, 8));
cout << prev_frame << " \n";
Mat grad_x, grad_y;
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
Sobel(prev_frame, grad_x, ddepth, 1, 0, 3, scale, delta, BORDER_DEFAULT);
Sobel(prev_frame, grad_y, ddepth, 0, 1, 3, scale, delta, BORDER_DEFAULT);
cout << grad_x << endl;
double min, max;
minMaxLoc(grad_x, &min, &max);
cout << min << endl;
cout << max << endl;
/* ALREADY in cout <<grad_x
for (int j = 0; j < grad_x.rows; j++)
{
for (int i = 0; i < grad_x.cols; i++)
{
for (int j = 0; j < grad_x.rows; j++)
{
cout << grad_x.at<short>(j, i)<<"\t" ;
}
cout << endl;
}
}*/
}