OpenCV Android错误的坐标

OpenCV Android错误的坐标,android,c++,opencv,Android,C++,Opencv,我在Android版OpenCV上遇到了一个非常奇怪的问题: 当我使用Mat.at访问像素时,屏幕上的像素出现错误: 一个简单的例子: for( double y = (mat.rows - h) / 2 ; y < (mat.rows + h) / 2 ; y++ ) { for( double x = (mat.cols - w) / 2; x < (mat.cols + w) / 2; x++ ) { for( int c = 0; c < 3;

我在Android版OpenCV上遇到了一个非常奇怪的问题: 当我使用Mat.at访问像素时,屏幕上的像素出现错误: 一个简单的例子:

for( double y = (mat.rows - h) / 2 ; y < (mat.rows + h) / 2 ; y++ ) {
    for( double x = (mat.cols - w) / 2; x < (mat.cols + w) / 2; x++ ) {
        for( int c = 0; c < 3; c++ ) {
            mat.at<Vec3b>(y,x)[c] =
                saturate_cast<uchar>( 255 );

        }
    }
}

circle(mat, Point((mat.cols - w) / 2, (mat.rows - h) / 2), 10, Scalar(255,0,0,255));
circle(mat, Point((mat.cols + w) / 2, (mat.rows - h) / 2), 10, Scalar(255,0,0,255));
circle(mat, Point((mat.cols - w) / 2, (mat.rows + h) / 2), 10, Scalar(255,0,0,255));
circle(mat, Point((mat.cols + w) / 2, (mat.rows + h) / 2), 10, Scalar(255,0,0,255));
for(双y=(材料排-h)/2;y<(材料排+h)/2;y++){
对于(双x=(mat.cols-w)/2;x<(mat.cols+w)/2;x++){
对于(int C=0;C<3;C++){
材料at(y,x)[c]=
饱和_型铸造(255);
}
}
}
圆(mat,点((mat.cols-w)/2,(mat.rows-h)/2),10,标量(255,0,0255));
圆(mat,点((mat.cols+w)/2,(mat.rows-h)/2),10,标量(255,0,0255));
圆(mat,点((mat.cols-w)/2,(mat.rows+h)/2),10,标量(255,0,0255));
圆(mat,点((mat.cols+w)/2,(mat.rows+h)/2),10,标量(255,0,0255));
我应该让角落与盒子对齐,但不是。 是否需要进行转换以访问真实坐标


这是一个长期的尝试,但它可能会帮助您。这是SDK仿真吗?我记得和thoes有过争执。当我在一台设备上尝试我的代码时,它就像一个魔咒一样工作。

您没有发布
mat
的初始化,但它似乎被初始化为type
CV\u 8UC4
。这意味着,使用
mat.at
访问图像会给您错误的像素位置。必须使用
at
访问四通道图像,以提供正确的像素位置,即使您仅修改了三个通道,如示例中所示

无关:不建议使用
double
作为计数器变量类型。

设备上没有its(三星S3)