基于Matlab单目摄像头的车道线及目标预测识别的学习笔记

本文档介绍了使用Matlab构建单目摄像头传感器模拟,用于车道边界和车辆检测。通过实例展示了如何将像素坐标转换为车辆坐标,并涵盖了自动驾驾驶工具箱中的坐标系统和计算机视觉技术。
摘要由CSDN通过智能技术生成

Matlab中演示文档Visual Perception Using Monocular Camera提供了一个简单的范例,在实际应用中会有很多需要注意的点。
Visual Perception Using Monocular Camera
This example shows how to construct a monocular camera sensor simulation capable of lane boundary and vehicle detections. The sensor will report these detections in vehicle coordinate system. In this example, you will learn about the coordinate system used by Automated Driving Toolbox™, and computer vision techniques involved in the design of a sample monocular camera sensor.
Overview
Vehicles that contain ADAS features or are designed to be fully autonomous rely on multiple sensors. These sensors can include sonar, radar, lidar and cameras. This example illustrates some of the concepts involved in the design of a monocular camera system. Such a sensor can accomplish many tasks, including:
Lane boundary detection
Detection of vehicles, people, and other objects
Distance estimation from the ego vehicle to obstacles
Subsequently, the readings returned by a monocular camera sensor can be used to issue lane departure warnings, collision warnings, or to design a lane keep assist control system. In conjunction with other sensors, it can also be used to implement an emergency braking system and other safety-critical features.
The example implements a subset of features found on a fully developed monocular camera system. It detects lane boundaries and backs of vehicles, and reports their locations in the vehicle coordinate system.
Define Camera Configuration
Knowing the camera’s intrinsic and extrinsic calibration parameters is critical to accurate conversion between pixel and vehicle coordinates.
Start by defining the camera’s intrinsic parameters. The parameters below were determined earlier using a camera calibration procedure that used a checkerboard calibration pattern. You can use the Camera Calibrator app to obtain them for your camera.
focalLength = [309.4362, 344.2161]; % [fx, fy] in pixel units
principalPoint = [318.9034, 257.5352]; % [cx, cy] optical center in pixel coordinates
imageSize = [480, 640]; % [nrows, mcols]

Note that the lens distortion coefficients were ignored, because there is little distortion in the data. The parameters are stored in a cameraIntrinsics object.
camIntrinsics = cameraIntrinsics(focalLength, principalPoint, imageSize);

Next, define the camera orientation with respect to the vehicle’s chassis. You will use this information to establish camera extrinsics that define the position of the 3-D camera coordinate system with respect to the vehicle coordinate system.
height = 2.1798; % mounting height in meters from the ground
pitch = 14; % pitch of the camera in degrees

The above quantities can be derived from the rotation and translation matrices returned by the extrinsics function. Pitch specifies the tilt of the camera from the horizontal position. For the camera used in this example, the roll and yaw of the sensor are both zero. The entire configuration defining the intrinsics and extrinsics is stored in the monoCamera object.
sensor = monoCamera(camIntrinsics, height, ‘Pitch’, pitch);
Note that the monoCamera object sets up a very specific vehicle coordinate system, where the X-axis points forward from the vehicle, the Y-axis points to the left of the vehicle, and the Z-axis points up from the ground.

By default, the origin of the coordinate system is on the ground, directly below the camera center defined by the camera’s focal point. The origin can be moved by using the SensorLocation property of the monoCamera object. Additionally, monoCamera provides imageToVehicle and vehicleToImage methods for converting between image and vehicle coordinate systems.
Note: The conversion between the coordinate systems assumes a flat road. It is based on establishing a homography matrix that maps locations on the imaging plane to locations on the road surface. Nonflat roads introduce errors in distance computations, especially at locations that are far from the vehicle.

Load a Frame of Video
Before processing the entire video, process a single video frame to illustrate the concepts involved in the design of a monocular camera sensor.
Start by creating a VideoReader object that opens a video file. To be memory efficient, VideoReader loads one video frame at a time.
videoName = ‘caltech_cordova1.avi’;
videoReader = VideoReader(videoName);

Read an interesting frame that contains lane markers and a vehicle.
timeStamp = 0.06667; % time from the beginning of the video
videoReader.CurrentTime = timeStamp; % point to the chosen frame

frame = readFrame(videoReader); % read frame at timeStamp seconds
imshow(frame) % display frame
Note: This example ignores lens distortion. If you were concerned about errors in distance measurements introduced by the lens distortion, at this point you would use the undistortImage function to remove the lens distortion.

Create Bird’s-Eye-View Image
There are many ways to segment and detect lane markers. One approach involves the use of a bird’s-eye-view image transform. Although it incurs computational cost, this transform offers one major advantage. The lane markers in the bird’s-eye view are of uniform thickness, thus simplifying the segmentation process. The lane markers belonging to the same lane also become parallel, thus making further analysis easier.
Given the camera setup, the birdsEyeView object transforms the original image to the bird’s-eye view. This object lets you specify the area that you want to transform using vehicle coordinates. Note that the vehicle coordinate units were established by the monoCamera object, when the camera mounting height was specified in meters. For example, if the height was specified in millimeters, the rest of the simulation would use millimeters.
%

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值