我找到了一个想与他人分享的解决方案
Mat frame = new Mat();
VideoCapture camera = new VideoCapture(0);
int frame_width = (int)camera.get(Videoio.CAP_PROP_FRAME_WIDTH); //for example 640
int frame_height = (int)camera.get(Videoio.CV_CAP_PROP_FRAME_HEIGHT); //for example 480
Point middle_of_frame_left = new Point();
Point middle_of_frame_right = new Point();
middle_of_frame_left.x = 0;
middle_of_frame_left.y = frame_height/2;
//middle_of_frame_left coordinate will be point(0,240)
middle_of_frame_right.x = frame_width;
middle_of_frame_right.y = frame_height/2;
//middle_of_frame_right coordinate will be point(640,240)
while (true) {
// If next video frame is available
if (camera.read(frame)) {
Imgproc.line(frame, middle_of_frame_left, middle_of_frame_right,new Scalar(0, 0, 255) , 5);
}
}