如何裁剪图像并只保留图像的下半部分?
我试过:
Mat cropped frame = frame(Rect(frame.cols/2, 0, frame.cols, frame.rows/2));
但它给了我一个错误。
我也试过:
double min, max;
Point min_loc, max_loc;
minMaxLoc(frame, &min, &max, &min_loc, &max_loc);
int x = min_loc.x + (max_loc.x - min_loc.x) / 2;
Mat croppedframe = = frame(Rect(x, min_loc.y, frame.size().width, frame.size().height / 2));
但效果不佳。
最佳答案
这是适合所有初学者的 python 版本。
def crop_bottom_half(image):
cropped_img = image[image.shape[0]/2:image.shape[0]]
return cropped_img
关于opencv - 在 OpenCV 中裁剪一半图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38665277/