0
我試圖計算每個CV_8UC3顏色通道的絕對差值,乘以使用OpenCV 2.4.8的Java中的比例!Java Pixel Access OpenCV 2.4.8
我知道,Java不使用UCHAR,並認爲在Java中最接近的是一個字符串[]
但沒有工作,所以我用了很短的話,我得到:
"error: cannot find symbol
short[] ptr_entry = image_entry.<short>ptr(row);
symbol: method <short>ptr(int) location: variable image_entry of type Mat
我嘗試了使用at方法的可能性,但是我無法在java中使用它!
for (int row = 0; row < image_entry.rows(); ++row)
{
short[] ptr_entry = image_entry.<short>ptr(row);
uchar[] ptr_compressed = image_compressed.<uchar>ptr(row);
uchar[] ptr_output = image_output.<uchar>ptr(row);
for (int col = 0; col < image_entry.cols(); col++)
{
// Calculation of the absolute difference in each color channel, multiplied by the scale
ptr_output[0] = Math.abs(ptr_entry[0] - ptr_compressed[0]) * scale;
ptr_output[1] = Math.abs(ptr_entry[1] - ptr_compressed[1]) * scale;
ptr_output[2] = Math.abs(ptr_entry[2] - ptr_compressed[2]) * scale;
ptr_entry += 3;
ptr_compressed += 3;
ptr_output += 3;
}
}
有何建議?
明天再說一遍吧!我發現OpenCV的Java文檔有些缺乏,但是你的右眼是一個新的眼睛! –
使用get()和put()來訪問OpenCV for Java中的像素值! –
@TomC太好了。 – zindarod