My aim is to generate an error level analysis workflow using opencv and python, and I found this example doing what I need, but in C++ : Error level analysis in Image
While I managed to convert a part of it I'm really stuck on the loop rows part due to my lack of C++ knowledge, so I could use some support here.
This is what I managed to convert :
path=r'C:\****\training\pop_test'
image='source.jpg'
scale = 15
jpg_quality = 75
input_image= cv2.imread(os.path.join(path, image))
w,h,d = img.shape
# save tmp compressed file
cv2.imwrite(os.path.join(path, 'tmp.jpg'), input_image, [cv2.IMWRITE_JPEG_QUALITY, jpg_quality])
compressed_image= cv2.imread(os.path.join(path, 'tmp.jpg'))
# create matrice
output_image = np.zeros((w, h, d), dtype = "uint8")
And this is the C++ I'm having a hard time with :
for (int row = 0; row < input_image.rows; ++row)
{
const uchar* ptr_input = input_image.ptr<uchar>(row);
const uchar* ptr_compressed = compressed_image.ptr<uchar>(row);
uchar* ptr_out = output_image.ptr<uchar>(row);
for (int column = 0; column < input_image.cols; column++)
{
// Calc abs diff for each color channel multiplying by a scale factor
ptr_out[0] = abs(ptr_input[0] - ptr_compressed[0]) * scale;
ptr_out[1] = abs(ptr_input[1] - ptr_compressed[1]) * scale;
ptr_out[2] = abs(ptr_input[2] - ptr_compressed[2]) * scale;
ptr_input += 3;
ptr_compressed += 3;
ptr_out += 3;
}
}
Anyone that can point me in the right direction?




