安卓获取白色像素并将其保存到java opencv中的数组中
我尝试在二值图像中获得一些白色像素,并将像素坐标保存到矩阵2x1的数组中。大概是这样的:
//x y
//2 3
//7 8
//13 16
//24 26
//78 103
//22 14
//16 18
我在安卓中使用opencv,在二值图像中获得白色像素,并将像素坐标保存到数组中进行处理。但我不知道如何将它保存到数组中,以及opencv中适合哪个数组(Matofpoint、MatofPoint2f、MatOfInt…)
这是我的代码,但它缺少
Size BinaryImage_size = BinaryImage.size();
double[] pixel_white = new double[0]; //just use 1 channel
MatOfFloat pointPositions = new MatOfFloat();
for(int i=0;i<BinaryImage.height;i++)
{
for(int j=0;jBinaryImage.width;j++)
{
pixel_white = BinaryImage.get(i,j);
if(pixel_white[0]>0)
{
// Maybe use it pointPositions.push_back(Point(i,j)); but it wrong
//which implementation i should here?
}
}
}
共 (0) 个答案