在图像中根据一条已知长度的线条去测另一根线条的长度,其中单目相机标定后如何对图像进行校正,图像二值化后如何测量线条所占的像素单元?哪位能不能详细的讲一下
校正前
校正后
代码
import numpy as np
from cv2 import cv2 as cv
img_rgb = "t1.jpg"
R = np.eye(3)
img_size = (1920, 1080)
camera_matrix = np.array([1327.83423296061,-2.90391481077233,888.722966542323,0,1318.06225091592,499.363366357095,0,0,1]).reshape([3, 3])
distortion_coefficients = np.array([-0.262696321051489,0.0769783074655794,0.00289374480952410,0.00519247558807806]).reshape([4, 1])
mapx, mapy = cv.fisheye.initUndistortRectifyMap(camera_matrix, distortion_coefficients, R, camera_matrix, img_size,
cv.CV_32FC1)
srcImg = cv.imread(img_rgb)
# srcImg = cv.imread("camera.bmp")
resultImg = cv.remap(srcImg, mapx, mapy, cv.INTER_LINEAR, cv.BORDER_CONSTANT)
cv.imwrite("r2.png", resultImg)
图像在二值化后如何测量直线所占的像素单元不知道怎么搞