我想从像素值不为零的图像中得到(x,Y)坐标。我在这段代码中遇到以下错误: 错误访问:
camera.cpp
void Camera ::write_uint8_image_1(uint8_image_t *image, int *output)
{
int index = 1;
for(uint32_t i = 0; i < image->h; i++)
{
for(uint32_t j = 0; j < image->w; j++)
{
if(image->data[i * image->w + j] != 0)
output[index++] = i;
output[index++] = j; /* error : bad access */
}
}
output[0] = index;
}
main.cpp
int output[800] = {0};
/*print output*/
C1.write_uint8_image_1(c.output_image, output);
for (int i = 1; i < output[0]; i++)
std::cout<< output[i] << " , ";