Apollo 10.0
自动驾驶开放平台
apollo::perception::camera 命名空间参考

命名空间

namespace  app
 
namespace  bevformer
 
namespace  caddn
 
namespace  darkSCNN
 
namespace  denseline
 
namespace  lane
 
namespace  location_refiner
 
namespace  petr
 
namespace  smoke
 
namespace  tracking_feature
 
namespace  yolo
 
namespace  yolox3d
 

class  AdaptiveKalmanFilter
 
struct  AnchorBox
 
class  BaseCalibrationService
 
class  BaseCalibrator
 
class  BaseCameraPerception
 
class  BaseCipv
 
class  BaseFeatureExtractor
 
class  BaseFilter
 
class  BaseLaneDetector
 
class  BaseLanePostprocessor
 
class  BaseMatcher
 
class  BaseObstacleDetector
 
class  BaseObstacleTracker
 
class  BasePostprocessor
 
class  BasePredictor
 
class  BaseSimilar
 
class  BaseTracker
 
class  BaseTransformer
 
struct  BBox3D
 
class  BEVFORMERObstacleDetector
 
class  BEVObstacleDetector
 
class  CaddnObstacleDetector
 
struct  CalibrationServiceInitOptions
 
struct  CalibrationServiceOptions
 
struct  CalibrationServiceParam
 
struct  CalibratorInitOptions
 
struct  CalibratorOptions
 
struct  CalibratorParams
 
struct  CameraDetectionBEV
 
class  CameraDetectionBevComponent
 
struct  CameraDetectionMultiStage
 
class  CameraDetectionMultiStageComponent
 
class  CameraDetectionOccComponent
 
struct  CameraDetectionSingleStage
 
class  CameraDetectionSingleStageComponent
 
struct  CameraFrame
 
class  CameraGroundPlaneDetector
 
struct  CameraGroundPlaneParams
 
struct  CameraLocationEstimation
 
class  CameraLocationEstimationComponent
 
struct  CameraLocationRefinement
 
class  CameraLocationRefinementComponent
 
struct  CameraPerceptionInitOptions
 
struct  CameraPerceptionOptions
 
struct  CameraStatus
 
class  CameraTrack
 
class  CameraTracker
 
class  CameraTrackingComponent
 
struct  CameraTrackingComponentConfig
 
struct  CameraTrackingFrame
 
class  CameraTrackManager
 
class  CarPose
 
struct  Channel
 
class  Cipv
 
struct  CipvInitOptions
 
struct  CipvOptions
 
struct  CipvParam
 
struct  CmpLanePointY
 
class  ConnectedComponent
 
class  CosineSimilar
 
class  DarkSCNNLaneDetector
 
class  DarkSCNNLanePostprocessor
 
class  DataProvider
 
struct  Debug
 
class  DenselineLaneDetector
 
class  DenselineLanePostprocessor
 
struct  DetectionChannel
 
struct  Dim
 
class  DisjointSet
 
struct  EgoLane
 
struct  EstimationChannel
 
class  ExtendedKalmanFilter
 
class  ExternalFeatureExtractor
 
struct  FeatureExtractorInitOptions
 
struct  FeatureExtractorLayer
 
struct  FeatureExtractorOptions
 
class  FirstOrderRCLowPassFilter
 
struct  GlobalConfig
 
class  GPUSimilar
 
struct  GridAndStride
 
class  GroundPlaneTracker
 
class  HistogramEstimator
 
struct  HistogramEstimatorParams
 
class  HMMatcher
 
struct  Hypothesis
 
struct  image2D
 
class  KalmanFilterConstState
 
class  KalmanFilterConstVelocity
 
struct  KalmanParam
 
class  LaneBasedCalibrator
 
class  LaneCameraPerception
 
struct  LaneDetectorInitOptions
 
struct  LaneDetectorOptions
 
struct  LaneLine
 
class  LaneLineCalibrator
 
struct  LanePointInfo
 
struct  LanePostprocessorInitOptions
 
struct  LanePostprocessorOptions
 
struct  LineSegment2D
 
struct  LocalCalibratorInitOptions
 
class  LocationRefinerPostprocessor
 
struct  MatcherConfig
 
struct  MatcherInitOptions
 
class  MaxNMeanFilter
 
class  MeanFilter
 
struct  MinDims
 
class  MotionServiceComponent
 
struct  MulticueParam
 
class  MultiCueTransformer
 
struct  NMSParam
 
struct  NormalizedBBox
 
struct  Object
 
class  ObjectMaintainer
 
struct  ObjectTemplate
 
class  ObjectTemplateManager
 
struct  ObjectTemplateMeta
 
class  ObjMapper
 
struct  ObjMapperOptions
 
struct  ObjMapperParams
 
class  ObjPostProcessor
 
struct  ObjPostProcessorOptions
 
struct  ObjPostProcessorParams
 
struct  ObstacleDetectorInitOptions
 
class  ObstacleReference
 
struct  ObstacleTrackerInitOptions
 
struct  ObstacleTrackerOptions
 
class  OMTObstacleTracker
 
struct  OmtParam
 
class  OnlineCalibrationService
 
struct  PatchIndicator
 
class  PlaneMotion
 
struct  PostprocessorInitOptions
 
struct  PostprocessorOptions
 
struct  PostprocessorParam
 
class  ProjectFeature
 
struct  Reference
 
struct  ReferenceParam
 
struct  RefinementChannel
 
struct  SensorCameraName
 
struct  SimilarMap
 
struct  SinglestageParam
 
class  SingleStageTransformer
 
class  SmokeObstacleDetector
 
struct  Target
 
struct  TargetParam
 
class  Timer
 
struct  TrackerConfig
 
struct  TrackerInitOptions
 
struct  TrackerOptions
 
class  TrackingFeatureExtractor
 
struct  TrackObject
 
struct  TrackObjectMatcherOptions
 
struct  TrafficLightFrame
 
struct  Transform
 
struct  TransformerInitOptions
 
struct  TransformerParams
 
class  TransformServer
 
class  UndistortionHandler
 
struct  VanishingPoint
 
class  Visualizer
 
struct  WeightParam
 
struct  YoloBlobs
 
class  YoloObstacleDetector
 
class  Yolox3DObstacleDetector
 

类型定义

typedef std::pair< size_t, size_t > TrackObjectPair
 
typedef std::shared_ptr< CameraTrackCameraTrackPtr
 
typedef std::shared_ptr< TrackObjectTrackObjectPtr
 
typedef std::vector< TrackObjectPtrTrackObjectPtrs
 
using Clock = apollo::cyber::Clock
 
typedef std::map< base::ObjectSubType, std::vector< float > > TemplateMap
 
typedef std::vector< base::Point3DFPoint3DSet
 
typedef std::vector< base::Point2DFPoint2DSet
 
typedef std::shared_ptr< apollo::drivers::ImageImageMsgType
 
typedef std::shared_ptr< localization::LocalizationEstimateLocalizationMsgType
 

枚举

enum class  TrackState { Predict , Associate2D , Associate3D , Track }
 
enum class  TemplateIndex { CAR_MIN_VOLUME_INDEX , VAN_MIN_VOLUME_INDEX , TRUCK_MIN_VOLUME_INDEX , BUS_MIN_VOLUME_INDEX }
 
enum class  LaneType { UNKNOWN_LANE = -1 , EGO_LANE = 0 , ADJACENT_LEFT_LANE = 1 , ADJACENT_RIGHT_LANE = 2 }
 

函数

 CYBER_REGISTER_COMPONENT (CameraDetectionBevComponent)
 
 REGISTER_OBSTACLE_DETECTOR (BEVObstacleDetector)
 
base::ObjectSubType GetSubtype (int cls, const std::vector< base::ObjectSubType > &types)
 Get the Subtype
 
void GetObjects (const base::BlobPtr< float > &box3ds, const base::BlobPtr< float > &labels, const base::BlobPtr< float > &scores, const std::vector< base::ObjectSubType > &types, float score_threshold, std::vector< base::ObjectPtr > *objects)
 Get the Objects objects from blob
 
void FillBBox3d (const float *bbox, base::ObjectPtr obj)
 Fill the 3d bbox to object
 
void Resize (cv::Mat *img, cv::Mat *img_n, int width, int height)
 Image resize function
 
void Crop (cv::Mat *img, cv::Mat *img_n, int x, int y, int width, int height)
 Image crop function
 
void Normalize (const std::vector< float > &mean, const std::vector< float > &std, float scale, cv::Mat *img)
 Image normalize function
 
 PERCEPTION_REGISTER_REGISTERER (BaseObstacleDetector)
 
 CYBER_REGISTER_COMPONENT (CameraDetectionMultiStageComponent)
 
void get_intersect_bbox (const NormalizedBBox &bbox1, const NormalizedBBox &bbox2, NormalizedBBox *intersect_bbox)
 Get the intersect bbox object
 
float get_bbox_size (const NormalizedBBox &bbox)
 
float get_jaccard_overlap (const NormalizedBBox &bbox1, const NormalizedBBox &bbox2)
 Get the jaccard overlap object
 
void get_max_score_index (const std::vector< float > &scores, const float threshold, const int top_k, std::vector< std::pair< float, int > > *score_index_vec)
 Get the max score index object
 
void apply_softnms_fast (const std::vector< NormalizedBBox > &bboxes, std::vector< float > *scores, const float score_threshold, const float nms_threshold, const int top_k, std::vector< int > *indices, bool is_linear, const float sigma)
 softnms for objects
 
void apply_boxvoting_fast (std::vector< NormalizedBBox > *bboxes, std::vector< float > *scores, const float conf_threshold, const float nms_threshold, const float sigma, std::vector< int > *indices)
 filter target detection results based on given thresholds and parameters.
 
void apply_nms_fast (const std::vector< NormalizedBBox > &bboxes, const std::vector< float > &scores, const float score_threshold, const float nms_threshold, const float eta, const int top_k, std::vector< int > *indices)
 nms for objects
 
void filter_bbox (const MinDims &min_dims, std::vector< base::ObjectPtr > *objects)
 filter out the objects in the object array based on the given minimum dimension conditions and retain the objects that meet the conditions
 
void recover_bbox (int roi_w, int roi_h, int offset_y, std::vector< base::ObjectPtr > *objects)
 recover detect bbox result to raw image
 
void fill_base (base::ObjectPtr obj, const float *bbox)
 add bbox value to object
 
void fill_bbox3d (bool with_bbox3d, base::ObjectPtr obj, const float *bbox)
 add alpha h w l to object
 
void fill_frbox (bool with_frbox, base::ObjectPtr obj, const float *bbox)
 add car front and backward bbox value to object
 
void fill_lights (bool with_lights, base::ObjectPtr obj, const float *bbox)
 add car lights value to object
 
void fill_ratios (bool with_ratios, base::ObjectPtr obj, const float *bbox)
 add ratio value to object
 
void fill_area_id (bool with_flag, base::ObjectPtr obj, const float *data)
 add area id value to object
 
int get_area_id (float visible_ratios[4])
 calculate the area id based on the visible ratios
 
const float * get_cpu_data (bool flag, const base::Blob< float > &blob)
 
void get_objects_cpu (const YoloBlobs &yolo_blobs, const cudaStream_t &stream, const std::vector< base::ObjectSubType > &types, const NMSParam &nms, const yolo::ModelParam &model_param, float light_vis_conf_threshold, float light_swt_conf_threshold, base::Blob< bool > *overlapped, base::Blob< int > *idx_sm, std::vector< base::ObjectPtr > *objects)
 Get the objects cpu object
 
__host__ __device__ float sigmoid_gpu (float x)
 
__host__ __device__ float bbox_size_gpu (const float *bbox, const bool normalized)
 
__host__ __device__ float jaccard_overlap_gpu (const float *bbox1, const float *bbox2)
 
template<typename T >
bool sort_score_pair_descend (const std::pair< float, T > &pair1, const std::pair< float, T > &pair2)
 
void apply_nms (const bool *overlapped, const int num, std::vector< int > *indices)
 Get all boxes with score larger than threshold
 
void apply_nms_gpu (const float *bbox_data, const float *conf_data, const std::vector< int > &origin_indices, const int bbox_step, const float confidence_threshold, const int top_k, const float nms_threshold, std::vector< int > *indices, base::Blob< bool > *overlapped, base::Blob< int > *idx_sm, const cudaStream_t &_stream)
 Get all boxes with score larger than threshold
 
void compute_overlapped_by_idx_gpu (const int nthreads, const float *bbox_data, const float overlap_threshold, const int *idx, const int num_idx, bool *overlapped_data, const cudaStream_t &_stream)
 Get all boxes with score larger than threshold
 
int get_objects_gpu (const YoloBlobs &yolo_blobs, const cudaStream_t &stream, const std::vector< base::ObjectSubType > &types, const NMSParam &nms, const yolo::ModelParam &model_param, float light_vis_conf_threshold, float light_swt_conf_threshold, base::Blob< bool > *overlapped, base::Blob< int > *idx_sm, const std::map< base::ObjectSubType, std::vector< int > > &indices, const std::map< base::ObjectSubType, std::vector< float > > &conf_scores)
 Get the objects gpu object
 
const float * get_gpu_data (bool flag, const base::Blob< float > &blob)
 Get the gpu data object
 
 REGISTER_OBSTACLE_DETECTOR (YoloObstacleDetector)
 
void YoloxGetAllObjects (const float *data, const yolox3d::ModelParam &model_param, const float scale, std::vector< std::vector< float > > *objects_out)
 Get all objects accoring to confidence
 
float ComputeYoloxOverlap (const base::Rect< float > &a, const base::Rect< float > &b)
 
void YoloxFillBase (const std::vector< float > &detect, const int width, const int height, const int image_width, const int image_height, base::ObjectPtr obj)
 Get 2dbbox for objects
 
void YoloxFillBbox3d (const yolox3d::ModelParam &model_param, const std::vector< float > &detect, base::ObjectPtr obj)
 Add 3d bbox values for objects
 
float YoloxBboxIOU (const std::vector< float > &box1, const std::vector< float > &box2)
 Computes IoU between bboxes.
 
void YoloxTruncated (base::ObjectPtr obj, const int image_width, const int image_height)
 object is truncated or not
 
void YoloxGetObjectsCpu (const std::shared_ptr< base::Blob< float > > &objects_blob, const yolox3d::ModelParam &model_param, const yolox3d::NMSParam &nms_param, const int width, const int height, const int image_width, const int image_height, std::vector< base::ObjectPtr > *objects)
 Return Yolox Objects
 
template<typename T >
constexpr T Yoloxclamp (const T &val, const T &low, const T &high)
 Clamp target value between low and high tools for iou
 
void AddShape3DYolox (std::map< std::string, std::vector< int > > *shape_map, const google::protobuf::RepeatedPtrField< common::ModelBlob > &model_blobs)
 
std::vector< std::string > GetBlobNames3DYolox (const google::protobuf::RepeatedPtrField< common::ModelBlob > &model_blobs)
 
cv::Mat resizeKeepAspectRatioYolox (const cv::Mat &input, const cv::Size &dstSize, const cv::Scalar &bgcolor)
 
 REGISTER_OBSTACLE_DETECTOR (Yolox3DObstacleDetector)
 
 CYBER_REGISTER_COMPONENT (CameraDetectionOccComponent)
 
 REGISTER_OBSTACLE_DETECTOR (BEVFORMERObstacleDetector)
 
void BevFormerResize (cv::Mat *img, cv::Mat *img_n, int width, int height)
 Image resize function
 
void BevFormerCrop (cv::Mat *img, cv::Mat *img_n, int x, int y, int width, int height)
 Image crop function
 
void BevFormerNormalize (const std::vector< float > &mean, const std::vector< float > &std, float scale, cv::Mat *img)
 Image normalize function
 
 PERCEPTION_REGISTER_REGISTERER (BaseMatcher)
 
 PERCEPTION_REGISTER_REGISTERER (BaseTracker)
 
 PERCEPTION_REGISTER_TRACKER (CameraTracker)
 
 PERCEPTION_REGISTER_MATCHER (HMMatcher)
 
void SetSemanticLabel (PointSemanticLabel label, uint8_t *value)
 
PointSemanticLabel GetSemanticLabel (uint8_t value)
 
bool IsSemanticLabel (PointSemanticLabel label, uint8_t value)
 
void SetSceneFlowLabel (PointSemanticLabel label, uint8_t *value)
 
PointSemanticLabel GetSceneFlowLabel (uint8_t value)
 
bool IsSceneFlowLabelEqual (PointSemanticLabel label, uint8_t value)
 
 CYBER_REGISTER_COMPONENT (CameraDetectionSingleStageComponent)
 
 REGISTER_OBSTACLE_DETECTOR (CaddnObstacleDetector)
 
void GetCaddnObjects (std::vector< base::ObjectPtr > *objects, const caddn::ModelParam &model_param, const std::vector< base::ObjectSubType > &types, const base::BlobPtr< float > &boxes, const base::BlobPtr< float > &labels, const base::BlobPtr< float > &scores)
 Get the Caddn Objects objects from Blob
 
void Bbox3dLidar2Camera (const Eigen::Matrix< float, 3, 4 > &V2C, const Eigen::Matrix< float, 3, 3 > &R, const float *bbox_lidar, std::vector< float > *bbox_camera)
 Get the Caddn Objects objects from Blob
 
void FillCaddnBbox3d (base::ObjectPtr obj, const float *bbox)
 Add objects values to object
 
void FilterByMinDims (const smoke::MinDims &min_dims, std::vector< base::ObjectPtr > *objects)
 
void RecoverBBox (int roi_w, int roi_h, int offset_y, std::vector< base::ObjectPtr > *objects)
 
void FillBBox (base::ObjectPtr obj, const float *bbox, int width, int height)
 
void FillBBox3d (base::ObjectPtr obj, const float *bbox)
 
void GetObjectsCpu (const std::shared_ptr< base::Blob< float > > &output_blob, const std::vector< base::ObjectSubType > &types, const smoke::ModelParam &model_param, std::vector< base::ObjectPtr > *objects, int width, int height)
 
 REGISTER_OBSTACLE_DETECTOR (SmokeObstacleDetector)
 
 CYBER_REGISTER_COMPONENT (CameraLocationEstimationComponent)
 
 PERCEPTION_REGISTER_REGISTERER (BaseTransformer)
 
 REGISTER_OBSTACLE_TRANSFORMER (MultiCueTransformer)
 
 REGISTER_OBSTACLE_TRANSFORMER (SingleStageTransformer)
 
 CYBER_REGISTER_COMPONENT (CameraLocationRefinementComponent)
 
 PERCEPTION_REGISTER_REGISTERER (BasePostprocessor)
 
 REGISTER_OBSTACLE_POSTPROCESSOR (LocationRefinerPostprocessor)
 
 CYBER_REGISTER_COMPONENT (CameraTrackingComponent)
 
 REGISTER_FEATURE_EXTRACTOR (ExternalFeatureExtractor)
 
 REGISTER_FEATURE_EXTRACTOR (ProjectFeature)
 
 REGISTER_FEATURE_EXTRACTOR (TrackingFeatureExtractor)
 
 PERCEPTION_REGISTER_REGISTERER (BaseFeatureExtractor)
 
 PERCEPTION_REGISTER_REGISTERER (BaseObstacleTracker)
 
 PERCEPTION_REGISTER_REGISTERER (BasePredictor)
 
void ProjectBox (const base::BBox2DF &box_origin, const Eigen::Matrix3d &transform, base::BBox2DF *box_projected)
 
 REGISTER_OBSTACLE_TRACKER (OMTObstacleTracker)
 
void ConvertGround3ToGround4 (const float &baseline, const std::vector< float > &k_mat, const std::vector< float > &ground3, std::vector< float > *ground4)
 
bool ConvertGround4ToGround3 (const float &baseline, const std::vector< float > &k_mat, const std::vector< float > &ground4, std::vector< float > *ground3)
 
void GetGroundPlanePitchHeight (const float &baseline, const std::vector< float > &k_mat, const std::vector< float > &ground3, float *pitch, float *cam_height)
 
void GetGround3FromPitchHeight (const std::vector< float > &k_mat, const float &baseline, const float &pitch, const float &cam_height, std::vector< float > *ground3)
 
template<typename T >
void GroundHypoGenFunc (const T *v, const T *d, T *p)
 
template<typename T >
void GroundFittingCostFunc (const T *p, const T *v, const T *d, int n, int *nr_inlier, int *inliers, T *cost, T error_tol)
 
cv::Mat GetImage (const std::string &path, bool to_rgb)
 
void Resize (const cv::Mat &input_img, cv::Mat *out_img, int width, int height, double fx, double fy, int interpolation)
 
std::vector< float > HWC2CHW (const cv::Mat &input_img)
 
void Resize (const cv::Mat &input_img, cv::Mat *out_img, cv::Size size, double fx=0, double fy=0, int interpolation=cv::INTER_LINEAR)
 
 PERCEPTION_REGISTER_CIPV (Cipv)
 
bool imageToBlob (const base::Image8U &image, base::Blob< uint8_t > *blob)
 
bool imageToGray (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height, const float coeffs[3])
 
bool swapImageChannels (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height, const int order[3])
 
bool dupImageChannels (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height)
 
bool imageRemap (const base::Image8U &src_img, base::Image8U *dst_img, const int src_width, const int src_height, const base::Blob< float > &map_x, const base::Blob< float > &map_y)
 
bool nppImageToBlob (const base::Image8U &image, base::Blob< uint8_t > *blob)
 
bool nppImageToGray (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height, const float coeffs[3])
 
bool nppSwapImageChannels (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height, const int order[3])
 
bool nppDupImageChannels (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height)
 
bool nppImageRemap (const base::Image8U &src_img, base::Image8U *dst_img, const int src_width, const int src_height, const base::Blob< float > &map_x, const base::Blob< float > &map_y)
 
bool rppInitDescriptor (RpptDescPtr &descPtr, int width, int height, int channels, int width_step)
 
bool rppImageToBlob (const base::Image8U &image, base::Blob< uint8_t > *blob)
 
bool rppImageToGray (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height, const float coeffs[3])
 
bool rppSwapImageChannels (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height, const int order[3])
 
__global__ void duplicate_kernel (const unsigned char *src, size_t src_width_step, uchar3 *dst, size_t dst_width_step, int width, int height)
 
bool rppDupImageChannels (const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height)
 
__global__ void remap_pln1_kernel (const unsigned char *src, size_t src_width_step, unsigned char *dst, size_t dst_width_step, const float *mapx, const float *mapy, int width, int height)
 
__global__ void remap_pkd3_kernel (const uchar3 *src, size_t src_width_step, uchar3 *dst, size_t dst_width_step, const float *mapx, const float *mapy, int width, int height)
 
bool rppImageRemap (const base::Image8U &src_img, base::Image8U *dst_img, const int src_width, const int src_height, const base::Blob< float > &map_x, const base::Blob< float > &map_y)
 
template<typename Dtype >
Dtype sigmoid (Dtype x)
 
template<typename Dtype >
Dtype gaussian (Dtype x, Dtype mu, Dtype sigma)
 
template<typename Dtype >
Dtype sqr (Dtype x)
 
std::ostream & operator<< (std::ostream &os, const CarPose &pose)
 
template<typename T >
CalAngleDiff (const T a1, const T a2)
 
template<typename T >
GetSharpAngle (const T &a, const T &b)
 
template<typename T >
GetJaccardIndex (const T *bbox_ref, const T &x_min, const T &y_min, const T &x_max, const T &y_max)
 
template<typename T >
void GenRotMatrix (const T &ry, T *rot)
 
template<typename T >
void GenCorners (T h, T w, T l, T *x_cor, T *y_cor, T *z_cor)
 
template<typename T >
bool Occlude (const T *bbox1, const T &h1, const T *bbox2, const T &h2)
 
template<typename T >
void GetBboxFromPts (const T *pts, const int &n, T *bbox)
 
template<typename T >
int GetMinIndexVec (const T *vec, const int &n)
 
template<typename T >
GetScoreViaRotDimensionCenter (const T *k_mat, int width, int height, const T *bbox, const T *rot, const T *hwl, const T *location, const bool &check_truncation, T *bbox_res=nullptr, T *bbox_near=nullptr)
 
template<typename T >
bool CheckXY (const T &x, const T &y, int width, int height)
 
template<typename T >
void UpdateOffsetZ (T x_start, T z_start, T x_end, T z_end, const std::pair< T, T > &range, T *z_offset)
 
template<typename T >
void GetDxDzForCenterFromGroundLineSeg (const LineSegment2D< T > &ls, const T *plane, const T *pts_c, const T *k_mat, int width, int height, T ratio_x_over_z, T *dx_dz, bool check_lowerbound=true)
 
bool Equal (double x, double target, double eps)
 
bool Equal (float x, float target, float eps)
 
bool LoadAnchors (const std::string &path, std::vector< float > *anchors)
 
bool LoadTypes (const std::string &path, std::vector< base::ObjectSubType > *types)
 
bool LoadExpand (const std::string &path, std::vector< float > *expands)
 
bool ResizeCPU (const base::Blob< uint8_t > &src_blob, std::shared_ptr< base::Blob< float > > dst_blob, int stepwidth, int start_axis)
 
void FillObjectPolygonFromBBox3D (base::Object *object_ptr)
 
template<typename T >
bool IsCovered (const base::Rect< T > &rect1, const base::Rect< T > &rect2, float thresh)
 
template<typename T >
bool IsCoveredHorizon (const base::Rect< T > &rect1, const base::Rect< T > &rect2, float thresh)
 
template<typename T >
bool IsCoveredVertical (const base::Rect< T > &rect1, const base::Rect< T > &rect2, float thresh)
 
template<typename T >
bool Contain (const std::vector< T > &array, const T &element)
 
template<typename T >
bool OutOfValidRegion (const base::BBox2D< T > box, const T width, const T height, const T border_size=0)
 
template<typename T >
bool OutOfValidRegion (const base::Rect< T > rect, const T width, const T height, const T border_size=0)
 
template<typename T >
void RefineBox (const base::Rect< T > &box_in, const T width, const T height, base::Rect< T > *box_out)
 
template<typename T >
void RefineBox (const base::BBox2D< T > &box_in, const T width, const T height, base::BBox2D< T > *box_out)
 
template<typename T >
void CalculateMeanAndVariance (const std::vector< T > &data, T *mean, T *variance)
 
 REGISTER_CALIBRATION_SERVICE (OnlineCalibrationService)
 
void GetYawVelocityInfo (const float &time_diff, const double cam_coord_cur[3], const double cam_coord_pre[3], const double cam_coord_pre_pre[3], float *yaw_rate, float *velocity)
 
 REGISTER_CALIBRATOR (LaneLineCalibrator)
 
 PERCEPTION_REGISTER_REGISTERER (BaseCalibrationService)
 
 PERCEPTION_REGISTER_REGISTERER (BaseCalibrator)
 
 PERCEPTION_REGISTER_REGISTERER (BaseCipv)
 
int WriteLanelines (const bool enabled, const std::string &save_path, const std::vector< base::LaneLine > &lane_objects)
 
int WriteCalibrationOutput (bool enabled, const std::string &out_path, const CameraFrame *frame)
 
 PERCEPTION_REGISTER_CAMERA_PERCEPTION (LaneCameraPerception)
 
bool FindCC (const std::vector< unsigned char > &src, int width, int height, const base::RectI &roi, std::vector< ConnectedComponent > *cc)
 
bool ImagePoint2Camera (const base::Point2DF &img_point, float pitch_angle, float camera_ground_height, const Eigen::Matrix3f &intrinsic_params_inverse, Eigen::Vector3d *camera_point)
 
bool CameraPoint2Image (const Eigen::Vector3d &camera_point, const Eigen::Matrix3f &intrinsic_params, base::Point2DF *img_point)
 
bool ComparePoint2DY (const base::Point2DF &point1, const base::Point2DF &point2)
 
bool FindKSmallValue (const float *distance, int dim, int k, int *index)
 
bool FindKLargeValue (const float *distance, int dim, int k, int *index)
 
template<typename Dtype >
bool PolyFit (const EigenVector< Eigen::Matrix< Dtype, 2, 1 > > &pos_vec, const int &order, Eigen::Matrix< Dtype, max_poly_order+1, 1 > *coeff, const bool &is_x_axis=true)
 
template<typename Dtype >
bool PolyEval (const Dtype &x, int order, const Eigen::Matrix< Dtype, max_poly_order+1, 1 > &coeff, Dtype *y)
 
template<typename Dtype >
bool RansacFitting (const EigenVector< Eigen::Matrix< Dtype, 2, 1 > > &pos_vec, EigenVector< Eigen::Matrix< Dtype, 2, 1 > > *selected_points, Eigen::Matrix< Dtype, 4, 1 > *coeff, const int max_iters=100, const int N=5, const Dtype inlier_thres=static_cast< Dtype >(0.1))
 
template<class T >
void QSwap_ (T *a, T *b)
 
template<class T >
void QuickSort (int *index, const T *values, int start, int end)
 
template<class T >
void QuickSort (int *index, const T *values, int nsize)
 
 PERCEPTION_REGISTER_REGISTERER (BaseCameraPerception)
 
 PERCEPTION_REGISTER_REGISTERER (BaseLaneDetector)
 
 PERCEPTION_REGISTER_REGISTERER (BaseLanePostprocessor)
 
 REGISTER_LANE_DETECTOR (DarkSCNNLaneDetector)
 
 REGISTER_LANE_DETECTOR (DenselineLaneDetector)
 
std::vector< base::LaneLinePositionTypespatialLUT ({base::LaneLinePositionType::UNKNOWN, base::LaneLinePositionType::FOURTH_LEFT, base::LaneLinePositionType::THIRD_LEFT, base::LaneLinePositionType::ADJACENT_LEFT, base::LaneLinePositionType::EGO_LEFT, base::LaneLinePositionType::EGO_CENTER, base::LaneLinePositionType::EGO_RIGHT, base::LaneLinePositionType::ADJACENT_RIGHT, base::LaneLinePositionType::THIRD_RIGHT, base::LaneLinePositionType::FOURTH_RIGHT, base::LaneLinePositionType::OTHER, base::LaneLinePositionType::CURB_LEFT, base::LaneLinePositionType::CURB_RIGHT})
 
template<typename T = float>
GetPolyValue (T a, T b, T c, T d, T x)
 
 REGISTER_LANE_POSTPROCESSOR (DarkSCNNLanePostprocessor)
 
 REGISTER_LANE_POSTPROCESSOR (DenselineLanePostprocessor)
 
 CYBER_REGISTER_COMPONENT (MotionServiceComponent)
 
bool LoadKittiLabel (onboard::CameraFrame *frame, const std::string &kitti_path, const std::string &dist_type)
 Read KITTI labels and fill to frame->detected_objects
 
bool FillImage (onboard::CameraFrame *frame, const std::string &file_name)
 Read image from file_name and fill in frame->data_provider
 
bool RecoveryImage (onboard::CameraFrame *frame, cv::Mat *cv_img)
 Recovery cv image from frame->data_provider
 
bool GetFileListFromPath (const std::string &file_path, std::vector< std::string > *file_list)
 Get the File List From Path object
 
bool GetFileListFromFile (const std::string &file_name, std::vector< std::string > *file_list)
 Get the File List From File object
 
bool SaveCameraDetectionResult (onboard::CameraFrame *frame, const std::string &file_name)
 Save detection result to file_name
 
bool SaveTfDetectionResult (onboard::CameraFrame *frame, const std::string &file_name)
 
bool SaveLaneDetectionResult (onboard::CameraFrame *frame, const std::string &file_name)
 
bool CameraVisualization (onboard::CameraFrame *frame, const std::string &file_name)
 Save visualization results to file_name(.jpg)
 
bool TfVisualization (onboard::CameraFrame *frame, const std::string &file_name)
 
bool LaneVisualization (onboard::CameraFrame *frame, const std::string &file_name)
 
Eigen::Matrix3d Camera2CarHomograph (const Eigen::Matrix3d &intrinsic, const Eigen::Matrix4d &extrinsic_camera2lidar, const Eigen::Matrix4d &extrinsic_lidar2imu, double pitch_adj)
 
bool InitDataProvider (onboard::CameraFrame *camera_frame)
 
bool TestDetection ()
 

变量

const std::map< std::string, base::ObjectSubTypekNuScenesName2SubTypeMap
 
constexpr float minExpPower = -10.0f
 
constexpr float maxExpPower = 5.0f
 
constexpr int anchorSizeFactor = 2
 
constexpr int numScales = 3
 
constexpr int kClassOfObstacles = 8
 
constexpr int kScoreIndex = 4
 
constexpr int kLabelIndex = 5
 
const base::ObjectSubType kYoloSubTypeYolox []
 
const std::map< int, std::string > kIndex2NuScenesName
 
const std::map< std::string, base::ObjectSubTypekApolloName2SubTypeMap
 
const std::map< int, std::string > kIndex2ApolloName
 
const int MAX_CAMERA_IDX = 2147483647
 
const std::map< std::string, base::ObjectSubTypekKITTIName2SubTypeMap
 
struct { 
 
customLess 
 
struct apollo::perception::camera::CameraFrame EIGEN_ALIGN16
 
constexpr float kMinVelocity = 10.0f
 
constexpr float kMaxDistObjectToLaneInMeter = 70.0f
 
constexpr float kMaxDistObjectToVirtualLaneInMeter = 10.0f
 
constexpr float kMaxDistObjectToLaneInPixel = 10.0f
 
const std::size_t kDropsHistorySize = 20
 
const std::size_t kMaxObjectNum = 100
 
const std::size_t kMaxAllowedSkipObject = 10
 
const uint32_t THREADS_PER_BLOCK_X = 32
 
const uint32_t THREADS_PER_BLOCK_Y = 32
 
std::vector< base::ObjectSubTypekTypeCanBeRef
 
std::vector< base::ObjectSubTypekTypeRefinedByTemplate
 
std::vector< base::ObjectSubTypekTypeRefinedByRef
 
const float kYawRateDefault = 0.0f
 
const float kVelocityDefault = 8.333f
 
const float kTimeDiffDefault = 0.067f
 
std::map< base::LaneLinePositionType, int > spatialLUTind
 
const std::map< std::string, base::ObjectSubTypeobject_subtype_map
 
std::vector< cv::Scalar > colorlistobj
 
std::map< base::LaneLinePositionType, cv::Scalar > colormapline
 

类型定义说明

◆ CameraTrackPtr

在文件 camera_track.h162 行定义.

◆ Clock

◆ ImageMsgType

◆ LocalizationMsgType

◆ Point2DSet

在文件 common_functions.h35 行定义.

◆ Point3DSet

在文件 common_functions.h34 行定义.

◆ TemplateMap

typedef std::map<base::ObjectSubType, std::vector<float> > apollo::perception::camera::TemplateMap

在文件 object_template_manager.h43 行定义.

◆ TrackObjectPair

typedef std::pair<size_t, size_t> apollo::perception::camera::TrackObjectPair

在文件 base_matcher.h34 行定义.

◆ TrackObjectPtr

在文件 track_object.h36 行定义.

◆ TrackObjectPtrs

在文件 track_object.h37 行定义.

枚举类型说明

◆ LaneType

枚举值
UNKNOWN_LANE 
EGO_LANE 
ADJACENT_LEFT_LANE 
ADJACENT_RIGHT_LANE 

在文件 denseline_lane_postprocessor.h35 行定义.

◆ TemplateIndex

枚举值
CAR_MIN_VOLUME_INDEX 
VAN_MIN_VOLUME_INDEX 
TRUCK_MIN_VOLUME_INDEX 
BUS_MIN_VOLUME_INDEX 

在文件 object_template_manager.h36 行定义.

◆ TrackState

函数说明

◆ AddShape3DYolox()

void apollo::perception::camera::AddShape3DYolox ( std::map< std::string, std::vector< int > > *  shape_map,
const google::protobuf::RepeatedPtrField< common::ModelBlob > &  model_blobs 
)

在文件 yolox3d_obstacle_detector.cc58 行定义.

60 {
61 for (const auto &blob : model_blobs) {
62 std::vector<int> shape(blob.shape().begin(), blob.shape().end());
63 shape_map->insert(std::make_pair(blob.name(), shape));
64 }
65}

◆ apply_boxvoting_fast()

void apollo::perception::camera::apply_boxvoting_fast ( std::vector< NormalizedBBox > *  bboxes,
std::vector< float > *  scores,
const float  conf_threshold,
const float  nms_threshold,
const float  sigma,
std::vector< int > *  indices 
)

filter target detection results based on given thresholds and parameters.

参数
bboxes2d bbox results
scoresscores results of bbox
conf_thresholdconfidence threshold
nms_thresholdnms threshold
sigmasigma parameter
indicesindices of matched objects

在文件 postprocess.cc138 行定义.

141 {
142 if (bboxes->size() == 0) {
143 return;
144 }
145 indices->clear();
146 for (int i = 0; i < static_cast<int>(bboxes->size()); i++) {
147 (*bboxes)[i].mask = false;
148 if ((*scores)[i] > conf_threshold) {
149 indices->push_back(i);
150 }
151 }
152 for (int count = 0; count < static_cast<int>(indices->size()); count++) {
153 int max_box_idx = 0;
154
155 for (int i = 1; i < static_cast<int>(indices->size()); i++) {
156 int idx = indices->at(i);
157 if ((*bboxes)[idx].mask) {
158 continue;
159 }
160 if ((*scores)[idx] > (*scores)[max_box_idx]) {
161 max_box_idx = idx;
162 }
163 }
164
165 NormalizedBBox &best_bbox = (*bboxes)[max_box_idx];
166 best_bbox.score = (*scores)[max_box_idx];
167 best_bbox.mask = true;
168 float s_vt = (*scores)[max_box_idx];
169 float x1_vt = best_bbox.xmin * s_vt;
170 float x2_vt = best_bbox.xmax * s_vt;
171 float y1_vt = best_bbox.ymin * s_vt;
172 float y2_vt = best_bbox.ymax * s_vt;
173 for (int i = 0; i < static_cast<int>(indices->size()); i++) {
174 int sub_it = indices->at(i);
175 if ((*bboxes)[sub_it].mask) {
176 continue;
177 }
178 float cur_overlap = 0.;
179 cur_overlap = get_jaccard_overlap(best_bbox, (*bboxes)[sub_it]);
180 if (sigma == 0) {
181 (*bboxes)[sub_it].mask = true;
182 } else {
183 (*scores)[sub_it] *=
184 static_cast<float>(exp(-1.0 * pow(cur_overlap, 2) / sigma));
185 }
186 (*bboxes)[sub_it].score = (*scores)[sub_it];
187
188 // Remove it if necessary
189 if (cur_overlap > nms_threshold) {
190 float s_vt_cur = (*bboxes)[sub_it].score;
191 s_vt += s_vt_cur;
192 x1_vt += (*bboxes)[sub_it].xmin * s_vt_cur;
193 x2_vt += (*bboxes)[sub_it].xmax * s_vt_cur;
194 y1_vt += (*bboxes)[sub_it].ymin * s_vt_cur;
195 y2_vt += (*bboxes)[sub_it].ymax * s_vt_cur;
196 }
197 }
198 if (s_vt > 0.0001) {
199 (*bboxes)[max_box_idx].xmin = x1_vt / s_vt;
200 (*bboxes)[max_box_idx].xmax = x2_vt / s_vt;
201 (*bboxes)[max_box_idx].ymin = y1_vt / s_vt;
202 (*bboxes)[max_box_idx].ymax = y2_vt / s_vt;
203 }
204 }
205}
float get_jaccard_overlap(const NormalizedBBox &bbox1, const NormalizedBBox &bbox2)
Get the jaccard overlap object

◆ apply_nms()

void apollo::perception::camera::apply_nms ( const bool *  overlapped,
const int  num,
std::vector< int > *  indices 
)

Get all boxes with score larger than threshold

参数
overlappedoverlap result
numnumber of boxes with score larger than threshold
indicesindices of boxes with score larger than threshold

◆ apply_nms_fast()

void apollo::perception::camera::apply_nms_fast ( const std::vector< NormalizedBBox > &  bboxes,
const std::vector< float > &  scores,
const float  score_threshold,
const float  nms_threshold,
const float  eta,
const int  top_k,
std::vector< int > *  indices 
)

nms for objects

参数
bboxesinput bounding boxes
scoresinput scores, size sames to boxes
score_thresholdscore threshold
nms_thresholdNMS threshold
etaeta parameter
top_ktop_k parameter for nms
indicesindices of objects to keep

在文件 postprocess.cc207 行定义.

211 {
212 // Sanity check.
213 CHECK_EQ(bboxes.size(), scores.size())
214 << "bboxes and scores have different size.";
215
216 // Get top_k scores (with corresponding indices).
217 std::vector<std::pair<float, int>> score_index_vec;
218 get_max_score_index(scores, score_threshold, top_k, &score_index_vec);
219
220 // Do nms.
221 float adaptive_threshold = nms_threshold;
222 indices->clear();
223 while (!score_index_vec.empty()) {
224 const int idx = score_index_vec.front().second;
225 bool keep = true;
226 for (int k = 0; k < static_cast<int>(indices->size()); ++k) {
227 if (keep) {
228 const int kept_idx = (*indices)[k];
229 float overlap = get_jaccard_overlap(bboxes[idx], bboxes[kept_idx]);
230 keep = overlap <= adaptive_threshold;
231 } else {
232 break;
233 }
234 }
235 if (keep) {
236 indices->push_back(idx);
237 }
238 score_index_vec.erase(score_index_vec.begin());
239 if (keep && eta < 1 && adaptive_threshold > 0.5) {
240 adaptive_threshold *= eta;
241 }
242 }
243}
void get_max_score_index(const std::vector< float > &scores, const float threshold, const int top_k, std::vector< std::pair< float, int > > *score_index_vec)
Get the max score index object

◆ apply_nms_gpu()

void apollo::perception::camera::apply_nms_gpu ( const float *  bbox_data,
const float *  conf_data,
const std::vector< int > &  origin_indices,
const int  bbox_step,
const float  confidence_threshold,
const int  top_k,
const float  nms_threshold,
std::vector< int > *  indices,
base::Blob< bool > *  overlapped,
base::Blob< int > *  idx_sm,
const cudaStream_t &  _stream 
)

Get all boxes with score larger than threshold

参数
bbox_databbox data
conf_dataconf data
origin_indicesorigin indices
bbox_stepbbox step
confidence_thresholdonfidence threshold
top_ktop k
nms_thresholdnms threshold
indicesindices of boxes with score larger than threshold
overlappedoverlap result
idx_smindices of boxes with score larger than threshold
_streamstream

◆ apply_softnms_fast()

void apollo::perception::camera::apply_softnms_fast ( const std::vector< NormalizedBBox > &  bboxes,
std::vector< float > *  scores,
const float  score_threshold,
const float  nms_threshold,
const int  top_k,
std::vector< int > *  indices,
bool  is_linear,
const float  sigma 
)

softnms for objects

参数
bboxesvector of bboxes
scoresvector of scores
score_thresholdthreshold for scores
nms_thresholdthreshold for nms
top_ktop k scores
indicesindices of object
is_lineartrue if is linear
sigmasigma for gaussian kernel

在文件 postprocess.cc97 行定义.

101 {
102 // Sanity check.
103 CHECK_EQ(bboxes.size(), scores->size())
104 << "bboxes and scores have different size.";
105
106 // Get top_k scores (with corresponding indices).
107 std::vector<std::pair<float, int>> score_index_vec;
108 get_max_score_index(*scores, score_threshold, top_k, &score_index_vec);
109
110 // Do nms.
111 indices->clear();
112 while (!score_index_vec.empty()) {
113 auto best_it =
114 max_element(std::begin(score_index_vec), std::end(score_index_vec));
115 const int best_idx = (*best_it).second;
116 score_index_vec.erase(best_it);
117 const NormalizedBBox &best_bbox = bboxes[best_idx];
118 indices->push_back(best_idx);
119 for (std::vector<std::pair<float, int>>::iterator it =
120 score_index_vec.begin();
121 it != score_index_vec.end();) {
122 int cur_idx = it->second;
123 const NormalizedBBox &cur_bbox = bboxes[cur_idx];
124
125 float cur_overlap = 0.;
126 cur_overlap = get_jaccard_overlap(best_bbox, cur_bbox);
127 if (is_linear) {
128 (*scores)[cur_idx] *= static_cast<float>((1.0 - cur_overlap));
129 } else {
130 (*scores)[cur_idx] *=
131 static_cast<float>(exp(-1.0 * pow(cur_overlap, 2) / sigma));
132 }
133 ++it;
134 }
135 }
136}

◆ Bbox3dLidar2Camera()

void apollo::perception::camera::Bbox3dLidar2Camera ( const Eigen::Matrix< float, 3, 4 > &  V2C,
const Eigen::Matrix< float, 3, 3 > &  R,
const float *  bbox_lidar,
std::vector< float > *  bbox_camera 
)

Get the Caddn Objects objects from Blob

参数
V2Cthe object container
Rthe rotation matrix
bbox_lidarlidar boxes
bbox_cameracamera boxes

在文件 postprocess.cc77 行定义.

80 {
81 float x = *(bbox_lidar + 0);
82 float y = *(bbox_lidar + 1);
83 float z = *(bbox_lidar + 2);
84 float l = *(bbox_lidar + 3);
85 float w = *(bbox_lidar + 4);
86 float h = *(bbox_lidar + 5);
87 float r = *(bbox_lidar + 6);
88 r = -r - M_PI / 2.0;
89 // 4*1
90 Eigen::Vector4f xyz_lidar;
91 xyz_lidar << x, y, z - h / 2.0, 1.0;
92 Eigen::Matrix<float, 1, 3> pts_rect =
93 xyz_lidar.transpose() * (V2C.transpose() * R.transpose());
94 std::vector<float> final_result{
95 pts_rect(0), pts_rect(1), pts_rect(2), l, h, w, r};
96 bbox_camera->assign(final_result.data(),
97 final_result.data() + final_result.size());
98}

◆ bbox_size_gpu()

__host__ __device__ float apollo::perception::camera::bbox_size_gpu ( const float *  bbox,
const bool  normalized 
)

◆ BevFormerCrop()

void apollo::perception::camera::BevFormerCrop ( cv::Mat *  img,
cv::Mat *  img_n,
int  x,
int  y,
int  width,
int  height 
)

Image crop function

参数
imgThe image to be cropped.
xThe x coordinate of the left side of the crop.
yThe y coordinate of the top side of the crop.
widthThe width of the crop image.
heightThe height of the crop image.

在文件 preprocess.cc28 行定义.

29 {
30 cv::Rect roi(x, y, width, height);
31 *img_n = (*img)(roi);
32}

◆ BevFormerNormalize()

void apollo::perception::camera::BevFormerNormalize ( const std::vector< float > &  mean,
const std::vector< float > &  std,
float  scale,
cv::Mat *  img 
)

Image normalize function

参数
meanThe mean value of the image.
stdThe standard deviation of the image.
scaleThe scale value of the image.
imThe image to be normalized.

在文件 preprocess.cc34 行定义.

36 {
37 ACHECK(std.size() == 3);
38 for (const auto std_value : std) {
39 ACHECK(std_value != 0.0);
40 }
41 if (scale) {
42 (*img).convertTo(*img, CV_32FC3, scale);
43 }
44 for (int h = 0; h < img->rows; ++h) {
45 for (int w = 0; w < img->cols; ++w) {
46 img->at<cv::Vec3f>(h, w)[0] =
47 (img->at<cv::Vec3f>(h, w)[0] - mean[0]) / std[0];
48 img->at<cv::Vec3f>(h, w)[1] =
49 (img->at<cv::Vec3f>(h, w)[1] - mean[1]) / std[1];
50 img->at<cv::Vec3f>(h, w)[2] =
51 (img->at<cv::Vec3f>(h, w)[2] - mean[2]) / std[2];
52 }
53 }
54}
#define ACHECK(cond)
Definition log.h:80
Definition future.h:29

◆ BevFormerResize()

void apollo::perception::camera::BevFormerResize ( cv::Mat *  img,
cv::Mat *  img_n,
int  width,
int  height 
)

Image resize function

参数
imgThe image to be resized.
widthThe width of the image.
heightThe height of the image.

在文件 preprocess.cc24 行定义.

24 {
25 cv::resize(*img, *img_n, cv::Size(width, height));
26}

◆ CalAngleDiff()

template<typename T >
T apollo::perception::camera::CalAngleDiff ( const T  a1,
const T  a2 
)

在文件 twod_threed_util.h61 行定义.

61 {
62 T diff1 = a1 - a2;
63 diff1 = diff1 < 0 ? -diff1 : diff1;
64 T diff2 = a1 - a2 + algorithm::Constant<T>::PI() * 2;
65 diff2 = diff2 < 0 ? -diff2 : diff2;
66 T diff3 = a1 - a2 - algorithm::Constant<T>::PI() * 2;
67 diff3 = diff3 < 0 ? -diff3 : diff3;
68 return std::min<T>(std::min<T>(diff1, diff2), diff3);
69}

◆ CalculateMeanAndVariance()

template<typename T >
void apollo::perception::camera::CalculateMeanAndVariance ( const std::vector< T > &  data,
T *  mean,
T *  variance 
)

在文件 util.h150 行定义.

151 {
152 if (!mean || !variance) {
153 return;
154 }
155 if (data.empty()) {
156 *mean = 0;
157 *variance = 0;
158 return;
159 }
160 T sum = std::accumulate(data.begin(), data.end(), static_cast<T>(0));
161 *mean = sum / data.size();
162
163 std::vector<T> diff(data.size());
164 std::transform(data.begin(), data.end(), diff.begin(),
165 [mean](T x) { return x - *mean; });
166 T sum_of_diff_sqrs = std::inner_product(diff.begin(), diff.end(),
167 diff.begin(), static_cast<T>(0));
168 *variance = sum_of_diff_sqrs / data.size();
169}

◆ Camera2CarHomograph()

Eigen::Matrix3d apollo::perception::camera::Camera2CarHomograph ( const Eigen::Matrix3d &  intrinsic,
const Eigen::Matrix4d &  extrinsic_camera2lidar,
const Eigen::Matrix4d &  extrinsic_lidar2imu,
double  pitch_adj 
)

在文件 visualizer.cc60 行定义.

64 {
65 AINFO << "intrinsic parameter of camera: " << intrinsic;
66 AINFO << "extrinsic parameter of camera to lidar: " << extrinsic_camera2lidar;
67 AINFO << "extrinsic parameter of lidar to imu: " << extrinsic_lidar2imu;
68 // rotate 90 degree around z axis to make x point forward
69 Eigen::Matrix4d Rz;
70 Rz << 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1;
71 Eigen::Matrix4d extrinsic_camera2car;
72 extrinsic_camera2car = extrinsic_camera2lidar * extrinsic_lidar2imu * Rz;
73 // adjust pitch in camera coords
74 Eigen::Matrix4d Rx;
75 Rx << 1, 0, 0, 0, 0, cos(pitch_adj), -sin(pitch_adj), 0, 0, sin(pitch_adj),
76 cos(pitch_adj), 0, 0, 0, 0, 1;
77 extrinsic_camera2car = extrinsic_camera2car * Rx;
78 AINFO << "extrinsic parameter from camera to car: " << extrinsic_camera2car;
79
80 // compute the homography matrix, such that H [u, v, 1]' ~ [X_l, Y_l, 1]
81 Eigen::Matrix3d K = intrinsic;
82 Eigen::Matrix3d R = extrinsic_camera2car.block(0, 0, 3, 3);
83 Eigen::Vector3d T = extrinsic_camera2car.block(0, 3, 3, 1);
84 Eigen::Matrix3d H;
85
86 H.block(0, 0, 3, 2) = (K * R.transpose()).block(0, 0, 3, 2);
87 H.block(0, 2, 3, 1) = -K * R.transpose() * T;
88 return H.inverse();
89}
#define AINFO
Definition log.h:42

◆ CameraPoint2Image()

bool apollo::perception::camera::CameraPoint2Image ( const Eigen::Vector3d &  camera_point,
const Eigen::Matrix3f &  intrinsic_params,
base::Point2DF img_point 
)

在文件 common_functions.cc226 行定义.

228 {
229 Eigen::Vector3f camera_point3f;
230 camera_point3f(0, 0) = static_cast<float>(camera_point(0, 0));
231 camera_point3f(1, 0) = static_cast<float>(camera_point(1, 0));
232 camera_point3f(2, 0) = static_cast<float>(camera_point(2, 0));
233 Eigen::MatrixXf img_point3f = intrinsic_params * camera_point3f;
234 if (fabs(img_point3f(2, 0)) < lane_eps_value) {
235 return false;
236 }
237 img_point->x = img_point3f(0, 0) / img_point3f(2, 0);
238 img_point->y = img_point3f(1, 0) / img_point3f(2, 0);
239 return true;
240}

◆ CameraVisualization()

bool apollo::perception::camera::CameraVisualization ( onboard::CameraFrame frame,
const std::string &  file_name 
)

Save visualization results to file_name(.jpg)

参数
frameCameraFrame
file_nameImage contains visualization results
返回
true
false

在文件 visualizer.cc40 行定义.

41 {
42 cv::Mat cv_img(frame->data_provider->src_height(),
43 frame->data_provider->src_width(), CV_8UC3,
44 cv::Scalar(0, 0, 0));
45
46 RecoveryImage(frame, &cv_img);
47
48 int obj_id = 0;
49 for (auto obj : frame->detected_objects) {
50 auto& supp = obj->camera_supplement;
51 auto& box = supp.box;
52 auto area_id = supp.area_id;
53
54 cv::rectangle(
55 cv_img,
56 cv::Point(static_cast<int>(box.xmin), static_cast<int>(box.ymin)),
57 cv::Point(static_cast<int>(box.xmax), static_cast<int>(box.ymax)),
58 cv::Scalar(0, 0, 0), 8);
59 float xmid = (box.xmin + box.xmax) / 2;
60 ACHECK(area_id > 0 && area_id < 9);
61 if (area_id & 1) {
62 cv::rectangle(
63 cv_img,
64 cv::Point(static_cast<int>(box.xmin), static_cast<int>(box.ymin)),
65 cv::Point(static_cast<int>(box.xmax), static_cast<int>(box.ymax)),
66 kFaceColors[area_id / 2], 2);
67 } else {
68 auto& tl = supp.cut_off_ratios[2];
69 auto& tr = supp.cut_off_ratios[3];
70 auto&& left_ratio = supp.visible_ratios[(area_id / 2) % 4];
71 auto w = box.xmax - box.xmin;
72 auto x = box.xmin;
73 auto tm = std::max(tl, tr);
74 if (tm > 1e-2) {
75 if (tl > tr) {
76 xmid = (x - w * tl) + (w + w * tl) * left_ratio;
77 } else if (tl < tr) {
78 xmid = x + (w + w * tr) * left_ratio;
79 }
80 } else {
81 xmid = x + w * left_ratio;
82 }
83 cv::rectangle(
84 cv_img,
85 cv::Point(static_cast<int>(box.xmin), static_cast<int>(box.ymin)),
86 cv::Point(static_cast<int>(xmid), static_cast<int>(box.ymax)),
87 kFaceColors[(area_id / 2) % 4], 3);
88 cv::rectangle(
89 cv_img, cv::Point(static_cast<int>(xmid), static_cast<int>(box.ymin)),
90 cv::Point(static_cast<int>(box.xmax), static_cast<int>(box.ymax)),
91 kFaceColors[area_id / 2 - 1], 2);
92 }
93 fprintf(stderr,
94 "obj-%02d: %.3f %.3f %.3f %.3f -- %.3f %.3f %.3f %.3f "
95 "-- %.0f %.0f %.0f %d\n",
96 obj_id, supp.visible_ratios[0], supp.visible_ratios[1],
97 supp.visible_ratios[2], supp.visible_ratios[3],
98 supp.cut_off_ratios[0], supp.cut_off_ratios[1],
99 supp.cut_off_ratios[2], supp.cut_off_ratios[3], box.xmin, xmid,
100 box.xmax, area_id);
101 std::stringstream text;
102 auto& name = base::kSubType2NameMap.at(obj->sub_type);
103 text << name[0] << name[1] << name[2] << " - " << obj_id++;
104 cv::putText(
105 cv_img, text.str(),
106 cv::Point(static_cast<int>(box.xmin), static_cast<int>(box.ymin)),
107 cv::FONT_HERSHEY_PLAIN, 2, cv::Scalar(255, 0, 0), 2);
108 }
109
110 cv::imwrite(file_name.c_str(), cv_img);
111 return true;
112}
bool RecoveryImage(onboard::CameraFrame *frame, cv::Mat *cv_img)
Recovery cv image from frame->data_provider
Definition util.cc:46
std::shared_ptr< camera::DataProvider > data_provider

◆ CheckXY()

template<typename T >
bool apollo::perception::camera::CheckXY ( const T &  x,
const T &  y,
int  width,
int  height 
)

在文件 twod_threed_util.h245 行定义.

245 {
246 T max_x = static_cast<T>(width - 1);
247 T max_y = static_cast<T>(height - 1);
248 return x <= max_x && x >= (T)0 && y <= max_y && y >= (T)0;
249}

◆ ComparePoint2DY()

bool apollo::perception::camera::ComparePoint2DY ( const base::Point2DF point1,
const base::Point2DF point2 
)

在文件 common_functions.cc241 行定义.

242 {
243 return point1.y < point2.y;
244}

◆ compute_overlapped_by_idx_gpu()

void apollo::perception::camera::compute_overlapped_by_idx_gpu ( const int  nthreads,
const float *  bbox_data,
const float  overlap_threshold,
const int *  idx,
const int  num_idx,
bool *  overlapped_data,
const cudaStream_t &  _stream 
)

Get all boxes with score larger than threshold

参数
nthreadsnumber of threads
bbox_databbox data
overlap_thresholdoverlap threshold
idxbbox index
num_idxnumber of bbox index
overlapped_dataoverlap result
_streamstream

◆ ComputeYoloxOverlap()

float apollo::perception::camera::ComputeYoloxOverlap ( const base::Rect< float > &  a,
const base::Rect< float > &  b 
)

在文件 postprocess.cc295 行定义.

296 {
297 base::Rect<float> intersection = a & b;
298 base::Rect<float> unionsection = a | b;
299 if (unionsection.Area() == 0) return 0.0f;
300 return intersection.Area() / unionsection.Area();
301}

◆ Contain()

template<typename T >
bool apollo::perception::camera::Contain ( const std::vector< T > &  array,
const T &  element 
)

在文件 util.h64 行定义.

64 {
65 for (const auto &item : array) {
66 if (item == element) {
67 return true;
68 }
69 }
70 return false;
71}

◆ ConvertGround3ToGround4()

void apollo::perception::camera::ConvertGround3ToGround4 ( const float &  baseline,
const std::vector< float > &  k_mat,
const std::vector< float > &  ground3,
std::vector< float > *  ground4 
)

在文件 camera_ground_plane.cc27 行定义.

30 {
31 CHECK_GT(baseline, 0.0f);
32 CHECK_EQ(k_mat.size(), 9U);
33 CHECK_EQ(ground3.size(), 3U);
34 CHECK_NOTNULL(ground4);
35 CHECK_EQ(ground4->size(), 4U);
36 const float &b = baseline;
37 const float &fx = k_mat[0];
38 const float &fy = k_mat[4];
39 const float &cy = k_mat[5];
40 ground4->data()[0] = 0.0f;
41 ground4->data()[1] = ground3[0] * fy;
42 ground4->data()[2] = ground3[0] * cy + ground3[2];
43 ground4->data()[3] = ground3[1] * b * fx;
44 float norm = algorithm::ISqrt(algorithm::ISquaresum3(ground4->data()));
45 algorithm::IScale4(ground4->data(), algorithm::IRec(norm));
46}

◆ ConvertGround4ToGround3()

bool apollo::perception::camera::ConvertGround4ToGround3 ( const float &  baseline,
const std::vector< float > &  k_mat,
const std::vector< float > &  ground4,
std::vector< float > *  ground3 
)

在文件 camera_ground_plane.cc48 行定义.

51 {
52 CHECK_GT(baseline, 0.0f);
53 CHECK_EQ(k_mat.size(), 9U);
54 CHECK_EQ(ground4.size(), 4U);
55 CHECK_NOTNULL(ground3);
56 CHECK_EQ(ground3->size(), 3U);
57 // normalization
58 float p[4] = {ground4[0], ground4[1], ground4[2], ground4[3]};
59 float norm = algorithm::ISqrt(algorithm::ISquaresum3(p));
60 algorithm::IScale4(p, algorithm::IRec(norm));
61 if (p[0] > 1e-3) {
62 AERROR << "Have roll in the ground plane: " << p[0];
63 ground3->assign(3, 0.f);
64 return false;
65 }
66 // no roll
67 const float &b = baseline;
68 const float &fx = k_mat[0];
69 const float &fy = k_mat[4];
70 const float &cy = k_mat[5];
71 ground3->data()[0] = p[1] * algorithm::IRec(fy);
72 ground3->data()[1] = p[3] * algorithm::IRec(b * fx);
73 ground3->data()[2] = p[2] - ground3->data()[0] * cy;
74 return true;
75}
#define AERROR
Definition log.h:44

◆ Crop()

void apollo::perception::camera::Crop ( cv::Mat *  img,
cv::Mat *  img_n,
int  x,
int  y,
int  width,
int  height 
)

Image crop function

参数
imgThe image to be cropped.
xThe x coordinate of the left side of the crop.
yThe y coordinate of the top side of the crop.
widthThe width of the crop image.
heightThe height of the crop image.

在文件 preprocess.cc28 行定义.

28 {
29 cv::Rect roi(x, y, width, height);
30 *img_n = (*img)(roi);
31}

◆ CYBER_REGISTER_COMPONENT() [1/8]

apollo::perception::camera::CYBER_REGISTER_COMPONENT ( CameraDetectionBevComponent  )

◆ CYBER_REGISTER_COMPONENT() [2/8]

apollo::perception::camera::CYBER_REGISTER_COMPONENT ( CameraDetectionMultiStageComponent  )

◆ CYBER_REGISTER_COMPONENT() [3/8]

apollo::perception::camera::CYBER_REGISTER_COMPONENT ( CameraDetectionOccComponent  )

◆ CYBER_REGISTER_COMPONENT() [4/8]

apollo::perception::camera::CYBER_REGISTER_COMPONENT ( CameraDetectionSingleStageComponent  )

◆ CYBER_REGISTER_COMPONENT() [5/8]

apollo::perception::camera::CYBER_REGISTER_COMPONENT ( CameraLocationEstimationComponent  )

◆ CYBER_REGISTER_COMPONENT() [6/8]

apollo::perception::camera::CYBER_REGISTER_COMPONENT ( CameraLocationRefinementComponent  )

◆ CYBER_REGISTER_COMPONENT() [7/8]

apollo::perception::camera::CYBER_REGISTER_COMPONENT ( CameraTrackingComponent  )

◆ CYBER_REGISTER_COMPONENT() [8/8]

apollo::perception::camera::CYBER_REGISTER_COMPONENT ( MotionServiceComponent  )

◆ dupImageChannels()

bool apollo::perception::camera::dupImageChannels ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height 
)

在文件 image_data_operations.cc55 行定义.

56 {
57 return nppDupImageChannels(src, dst, src_width, src_height);
58}
bool nppDupImageChannels(const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height)

◆ duplicate_kernel()

__global__ void apollo::perception::camera::duplicate_kernel ( const unsigned char *  src,
size_t  src_width_step,
uchar3 *  dst,
size_t  dst_width_step,
int  width,
int  height 
)

在文件 image_data_operations_rpp.h160 行定义.

162 {
163 const size_t i = hipBlockDim_x * hipBlockIdx_x + hipThreadIdx_x;
164 const size_t j = hipBlockDim_y * hipBlockIdx_y + hipThreadIdx_y;
165 image2D<unsigned char> src_img{src, src_width_step};
166 image2D<uchar3> dst_img{dst, dst_width_step};
167
168 if (i < width && j < height) {
169 unsigned char value = src_img(i, j);
170 dst_img(i, j).x = value;
171 dst_img(i, j).y = value;
172 dst_img(i, j).z = value;
173 }
174}

◆ Equal() [1/2]

bool apollo::perception::camera::Equal ( double  x,
double  target,
double  eps 
)

在文件 util.cc24 行定义.

24 {
25 return std::abs(x - target) < eps;
26}

◆ Equal() [2/2]

bool apollo::perception::camera::Equal ( float  x,
float  target,
float  eps 
)

在文件 util.cc27 行定义.

27 {
28 return std::abs(x - target) < eps;
29}

◆ fill_area_id()

void apollo::perception::camera::fill_area_id ( bool  with_flag,
base::ObjectPtr  obj,
const float *  data 
)

add area id value to object

参数
with_flagtrue: area id is exist
objobject result
dataarea id

在文件 postprocess.cc374 行定义.

374 {
375 if (with_flag) {
376 obj->camera_supplement.area_id = static_cast<int>(data[0]);
377 }
378}

◆ fill_base()

void apollo::perception::camera::fill_base ( base::ObjectPtr  obj,
const float *  bbox 
)

add bbox value to object

参数
objobject result
bbox[N, 4]

在文件 postprocess.cc316 行定义.

316 {
317 obj->camera_supplement.box.xmin = bbox[0];
318 obj->camera_supplement.box.ymin = bbox[1];
319 obj->camera_supplement.box.xmax = bbox[2];
320 obj->camera_supplement.box.ymax = bbox[3];
321}

◆ fill_bbox3d()

void apollo::perception::camera::fill_bbox3d ( bool  with_bbox3d,
base::ObjectPtr  obj,
const float *  bbox 
)

add alpha h w l to object

参数
with_bbox3dwhether to add alpha h w l to object
objobject
bboxthe bbox of object

在文件 postprocess.cc323 行定义.

323 {
324 if (with_box3d) {
325 obj->camera_supplement.alpha = bbox[0];
326 obj->size[2] = bbox[1];
327 obj->size[1] = bbox[2];
328 obj->size[0] = bbox[3];
329 }
330}

◆ fill_frbox()

void apollo::perception::camera::fill_frbox ( bool  with_frbox,
base::ObjectPtr  obj,
const float *  bbox 
)

add car front and backward bbox value to object

参数
with_frboxwhether to add car front and backward bbox value to object
objobject
bboxthe bbox of object

在文件 postprocess.cc332 行定义.

332 {
333 if (with_frbox) {
334 obj->camera_supplement.front_box.xmin = bbox[0];
335 obj->camera_supplement.front_box.ymin = bbox[1];
336 obj->camera_supplement.front_box.xmax = bbox[2];
337 obj->camera_supplement.front_box.ymax = bbox[3];
338
339 obj->camera_supplement.back_box.xmin = bbox[4];
340 obj->camera_supplement.back_box.ymin = bbox[5];
341 obj->camera_supplement.back_box.xmax = bbox[6];
342 obj->camera_supplement.back_box.ymax = bbox[7];
343 }
344}

◆ fill_lights()

void apollo::perception::camera::fill_lights ( bool  with_lights,
base::ObjectPtr  obj,
const float *  bbox 
)

add car lights value to object

参数
with_lightslights info
objobject to be filled
bboxthe bbox of object

在文件 postprocess.cc346 行定义.

346 {
347 if (with_lights) {
348 obj->car_light.brake_visible = bbox[0];
349 obj->car_light.brake_switch_on = bbox[1];
350 obj->car_light.left_turn_visible = bbox[2];
351 obj->car_light.left_turn_switch_on = bbox[3];
352 obj->car_light.right_turn_visible = bbox[4];
353 obj->car_light.right_turn_switch_on = bbox[5];
354 }
355}

◆ fill_ratios()

void apollo::perception::camera::fill_ratios ( bool  with_ratios,
base::ObjectPtr  obj,
const float *  bbox 
)

add ratio value to object

参数
with_ratiosratio value will be added to object
objobject to be filled
bboxthe bbox of object

在文件 postprocess.cc357 行定义.

357 {
358 if (with_ratios) {
359 // visible ratios of face a/b/c/d
360 obj->camera_supplement.visible_ratios[0] = bbox[0];
361 obj->camera_supplement.visible_ratios[1] = bbox[1];
362 obj->camera_supplement.visible_ratios[2] = bbox[2];
363 obj->camera_supplement.visible_ratios[3] = bbox[3];
364
365 // cut off on width and length (3D)
366 obj->camera_supplement.cut_off_ratios[0] = bbox[4];
367 obj->camera_supplement.cut_off_ratios[1] = bbox[5];
368 // cut off on left and right side (2D)
369 obj->camera_supplement.cut_off_ratios[2] = bbox[6];
370 obj->camera_supplement.cut_off_ratios[3] = bbox[7];
371 }
372}

◆ FillBBox()

void apollo::perception::camera::FillBBox ( base::ObjectPtr  obj,
const float *  bbox,
int  width,
int  height 
)

在文件 postprocess.cc80 行定义.

80 {
81 obj->camera_supplement.box.xmin = bbox[2] / width;
82 obj->camera_supplement.box.ymin = bbox[3] / height;
83 obj->camera_supplement.box.xmax = bbox[4] / width;
84 obj->camera_supplement.box.ymax = bbox[5] / height;
85}

◆ FillBBox3d() [1/2]

void apollo::perception::camera::FillBBox3d ( base::ObjectPtr  obj,
const float *  bbox 
)

在文件 postprocess.cc87 行定义.

87 {
88 obj->camera_supplement.alpha = bbox[1];
89 // todo: why obj size not put in camera_supplement
90 obj->size[2] = bbox[6];
91 obj->size[1] = bbox[7];
92 obj->size[0] = bbox[8];
93
94 obj->camera_supplement.local_center[0] = bbox[9];
95 obj->camera_supplement.local_center[1] = bbox[10];
96 obj->camera_supplement.local_center[2] = bbox[11];
97}

◆ FillBBox3d() [2/2]

void apollo::perception::camera::FillBBox3d ( const float *  bbox,
base::ObjectPtr  obj 
)

Fill the 3d bbox to object

参数
bbox
obj

在文件 postprocess.cc71 行定义.

71 {
72 obj->camera_supplement.local_center[0] = bbox[0];
73 obj->camera_supplement.local_center[1] = bbox[1];
74 obj->camera_supplement.local_center[2] = bbox[2];
75 // size: length, width, height of bbox
76 obj->size[0] = bbox[4];
77 obj->size[1] = bbox[3];
78 obj->size[2] = bbox[5];
79
80 // yaw
81 obj->theta = bbox[6];
82
83 obj->center(0) = static_cast<double>(obj->camera_supplement.local_center[0]);
84 obj->center(1) = static_cast<double>(obj->camera_supplement.local_center[1]);
85 obj->center(2) = static_cast<double>(obj->camera_supplement.local_center[2]);
86}

◆ FillCaddnBbox3d()

void apollo::perception::camera::FillCaddnBbox3d ( base::ObjectPtr  obj,
const float *  bbox 
)

Add objects values to object

参数
objobject
bboxbbox result

在文件 postprocess.cc109 行定义.

109 {
110 obj->camera_supplement.alpha = bbox[6];
111 obj->size[2] = bbox[3];
112 obj->size[1] = bbox[4];
113 obj->size[0] = bbox[5];
114
115 obj->camera_supplement.local_center[0] = bbox[0];
116 obj->camera_supplement.local_center[1] = bbox[1];
117 obj->camera_supplement.local_center[2] = bbox[2];
118}

◆ FillImage()

bool apollo::perception::camera::FillImage ( onboard::CameraFrame frame,
const std::string &  file_name 
)

Read image from file_name and fill in frame->data_provider

参数
frameonboard::CameraFrame
file_nameimage file
返回
true
false

在文件 util.cc28 行定义.

28 {
29 // Read image from file_name
30 cv::Mat image = cv::imread(file_name);
31 if (image.empty()) {
32 AERROR << "Read image failed! " << file_name;
33 return false;
34 }
35
36 // Fill image to frame->data_provider
37 bool res = frame->data_provider->FillImageData(image.rows, image.cols,
38 image.data, "bgr8");
39 if (!res) {
40 AERROR << "Fill image failed! " << file_name;
41 return false;
42 }
43 return true;
44}

◆ FillObjectPolygonFromBBox3D()

void apollo::perception::camera::FillObjectPolygonFromBBox3D ( base::Object object_ptr)

在文件 util.cc157 行定义.

157 {
158 if (!object_ptr) {
159 return;
160 }
161 const double length = object_ptr->size(0);
162 const double width = object_ptr->size(1);
163 // const double height = object_ptr->size(2);
164 double x1 = length / 2;
165 double x2 = -x1;
166 double y1 = width / 2;
167 double y2 = -y1;
168 double len = sqrt(object_ptr->direction[0] * object_ptr->direction[0] +
169 object_ptr->direction[1] * object_ptr->direction[1]);
170 double cos_theta = object_ptr->direction[0] / len;
171 double sin_theta = -object_ptr->direction[1] / len;
172
173 object_ptr->polygon.resize(4);
174 object_ptr->polygon[0].x =
175 x1 * cos_theta + y1 * sin_theta + object_ptr->center[0];
176 object_ptr->polygon[0].y =
177 y1 * cos_theta - x1 * sin_theta + object_ptr->center[1];
178 object_ptr->polygon[0].z = 0.0;
179
180 object_ptr->polygon[1].x =
181 x1 * cos_theta + y2 * sin_theta + object_ptr->center[0];
182 object_ptr->polygon[1].y =
183 y2 * cos_theta - x1 * sin_theta + object_ptr->center[1];
184 object_ptr->polygon[1].z = 0.0;
185
186 object_ptr->polygon[2].x =
187 x2 * cos_theta + y2 * sin_theta + object_ptr->center[0];
188 object_ptr->polygon[2].y =
189 y2 * cos_theta - x2 * sin_theta + object_ptr->center[1];
190 object_ptr->polygon[2].z = 0.0;
191
192 object_ptr->polygon[3].x =
193 x2 * cos_theta + y1 * sin_theta + object_ptr->center[0];
194 object_ptr->polygon[3].y =
195 y1 * cos_theta - x2 * sin_theta + object_ptr->center[1];
196 object_ptr->polygon[3].z = 0.0;
197}
virtual void resize(size_t size)
Definition point_cloud.h:88
Eigen::Vector3f direction
Definition object.h:47
PointCloud< PointD > polygon
Definition object.h:43

◆ filter_bbox()

void apollo::perception::camera::filter_bbox ( const MinDims min_dims,
std::vector< base::ObjectPtr > *  objects 
)

filter out the objects in the object array based on the given minimum dimension conditions and retain the objects that meet the conditions

参数
min_dimsminimum dimensions of the bounding box
objectslist of objects

在文件 postprocess.cc245 行定义.

246 {
247 int valid_obj_idx = 0;
248 int total_obj_idx = 0;
249 while (total_obj_idx < static_cast<int>(objects->size())) {
250 const auto &obj = (*objects)[total_obj_idx];
251 if ((obj->camera_supplement.box.ymax - obj->camera_supplement.box.ymin) >=
252 min_dims.min_2d_height &&
253 (min_dims.min_3d_height <= 0 ||
254 obj->size[2] >= min_dims.min_3d_height) &&
255 (min_dims.min_3d_width <= 0 || obj->size[1] >= min_dims.min_3d_width) &&
256 (min_dims.min_3d_length <= 0 ||
257 obj->size[0] >= min_dims.min_3d_length)) {
258 (*objects)[valid_obj_idx] = (*objects)[total_obj_idx];
259 ++valid_obj_idx;
260 }
261 ++total_obj_idx;
262 }
263 AINFO << valid_obj_idx << " of " << total_obj_idx << " obstacles kept";
264 objects->resize(valid_obj_idx);
265 AINFO << "Number of detected obstacles: " << objects->size();
266}

◆ FilterByMinDims()

void apollo::perception::camera::FilterByMinDims ( const smoke::MinDims min_dims,
std::vector< base::ObjectPtr > *  objects 
)

在文件 postprocess.cc26 行定义.

27 {
28 std::size_t valid_index = 0, cur_index = 0;
29 while (cur_index < objects->size()) {
30 const auto& obj = objects->at(cur_index);
31 float height =
32 obj->camera_supplement.box.ymax - obj->camera_supplement.box.ymin;
33 if (height >= min_dims.min_2d_height() &&
34 obj->size[2] >= min_dims.min_3d_height() &&
35 obj->size[1] >= min_dims.min_3d_width() &&
36 obj->size[0] >= min_dims.min_3d_length()) {
37 if (valid_index != cur_index)
38 objects->at(valid_index) = objects->at(cur_index);
39 ++valid_index;
40 }
41 ++cur_index;
42 }
43
44 objects->resize(valid_index);
45 AINFO << valid_index << " of " << cur_index << " obstacles kept";
46}

◆ FindCC()

bool apollo::perception::camera::FindCC ( const std::vector< unsigned char > &  src,
int  width,
int  height,
const base::RectI roi,
std::vector< ConnectedComponent > *  cc 
)

在文件 common_functions.cc83 行定义.

84 {
85 if (src.empty()) {
86 AERROR << "input image is empty";
87 return false;
88 }
89
90 cc->clear();
91 int x_min = roi.x;
92 int y_min = roi.y;
93 int x_max = x_min + roi.width - 1;
94 int y_max = y_min + roi.height - 1;
95 if (x_min < 0) {
96 AERROR << "x_min is less than zero: " << x_min;
97 return false;
98 }
99 if (y_min < 0) {
100 AERROR << "y_min is less than zero: " << y_min;
101 return false;
102 }
103 if (x_max >= width) {
104 AERROR << "x_max is larger than image width: " << x_max << "|" << width;
105 return false;
106 }
107 if (y_max >= height) {
108 AERROR << "y_max is larger than image height: " << y_max << "|" << height;
109 return false;
110 }
111 if (roi.width <= 1 && roi.height <= 1) {
112 AERROR << "too small roi range";
113 return false;
114 }
115
116 size_t total_pix = static_cast<size_t>(roi.width * roi.height);
117 std::vector<int> frame_label(total_pix);
118 DisjointSet labels(total_pix);
119 std::vector<int> root_map;
120 root_map.reserve(total_pix);
121
122 int x = 0;
123 int y = 0;
124 int left_val = 0;
125 int up_val = 0;
126 int cur_idx = 0;
127 int left_idx = 0;
128 int up_idx = 0;
129
130 // first loop logic
131 for (y = y_min; y <= y_max; y++) {
132 int row_start = y * width;
133 for (x = x_min; x <= x_max; x++, cur_idx++) {
134 left_idx = cur_idx - 1;
135 up_idx = cur_idx - width;
136
137 if (x == x_min) {
138 left_val = 0;
139 } else {
140 left_val = src[row_start + x - 1];
141 }
142
143 if (y == y_min) {
144 up_val = 0;
145 } else {
146 up_val = src[row_start - width + x];
147 }
148
149 if (src[row_start + x] > 0) {
150 if (left_val == 0 && up_val == 0) {
151 // current pixel is foreground and has no connected neighbors
152 frame_label[cur_idx] = labels.Add();
153 root_map.push_back(-1);
154 } else if (left_val != 0 && up_val == 0) {
155 // current pixel is foreground and has left neighbor connected
156 frame_label[cur_idx] = frame_label[left_idx];
157 } else if (left_val == 0 && up_val != 0) {
158 // current pixel is foreground and has up neighbor connect
159 frame_label[cur_idx] = frame_label[up_idx];
160 } else {
161 // current pixel is foreground
162 // and is connected to left and up neighbors
163 frame_label[cur_idx] = (frame_label[left_idx] > frame_label[up_idx])
164 ? frame_label[up_idx]
165 : frame_label[left_idx];
166 labels.Unite(frame_label[left_idx], frame_label[up_idx]);
167 }
168 } else {
169 frame_label[cur_idx] = -1;
170 }
171 } // end for x
172 } // end for y
173 AINFO << "subset number = " << labels.Size();
174
175 // second loop logic
176 cur_idx = 0;
177 int curt_label = 0;
178 int cc_count = 0;
179 for (y = y_min; y <= y_max; y++) {
180 for (x = x_min; x <= x_max; x++, cur_idx++) {
181 curt_label = frame_label[cur_idx];
182 if (curt_label >= 0 && curt_label < static_cast<int>(labels.Num())) {
183 curt_label = labels.Find(curt_label);
184 if (curt_label >= static_cast<int>(root_map.size())) {
185 AERROR << "curt_label should be smaller than root_map.size() "
186 << curt_label << " vs. " << root_map.size();
187 return false;
188 }
189 if (root_map.at(curt_label) != -1) {
190 (*cc)[root_map.at(curt_label)].AddPixel(x, y);
191 } else {
192 cc->push_back(ConnectedComponent(x, y));
193 root_map.at(curt_label) = cc_count++;
194 }
195 }
196 } // end for x
197 } // end for y
198 AINFO << "cc number = " << cc_count;
199
200 return true;
201}
uint32_t height
Height of point cloud
uint32_t width
Width of point cloud

◆ FindKLargeValue()

bool apollo::perception::camera::FindKLargeValue ( const float *  distance,
int  dim,
int  k,
int *  index 
)

在文件 common_functions.cc292 行定义.

292 {
293 if (dim < k) {
294 AWARN << "dim is smaller than k";
295 return false;
296 }
297 if (k <= 0) {
298 AWARN << "k is smaller than 0";
299 return false;
300 }
301 std::vector<float> large_value(k);
302 std::vector<int> large_index(k);
303 // sort the large value vector
304 QuickSort(&(large_index[0]), distance, k);
305 for (int i = 0; i < k; i++) {
306 index[i] = large_index[k - 1 - i];
307 large_value[i] = distance[index[i]];
308 }
309
310 for (int i = k; i < dim; i++) {
311 float min_value = large_value[k - 1];
312 if (distance[i] <= min_value) {
313 continue;
314 }
315 int locate_index = -1;
316 if (distance[i] > large_value[0]) {
317 locate_index = 0;
318 } else {
319 for (int j = 0; j < k - 1; j++) {
320 if (distance[i] <= large_value[j] &&
321 distance[i] >= large_value[j + 1]) {
322 locate_index = j + 1;
323 break;
324 } // if
325 } // for
326 } // else
327 if (locate_index == -1) {
328 return false;
329 }
330 for (int j = k - 2; j >= locate_index; j--) {
331 large_value[j + 1] = large_value[j];
332 index[j + 1] = index[j];
333 }
334 large_value[locate_index] = distance[i];
335 index[locate_index] = i;
336 }
337 return true;
338}
#define AWARN
Definition log.h:43

◆ FindKSmallValue()

bool apollo::perception::camera::FindKSmallValue ( const float *  distance,
int  dim,
int  k,
int *  index 
)

在文件 common_functions.cc246 行定义.

246 {
247 if (dim < k) {
248 AWARN << "dim is smaller than k";
249 return false;
250 }
251 if (k <= 0) {
252 AWARN << "k is smaller than 0";
253 return false;
254 }
255 std::vector<float> small_value(k);
256 // sort the small value vector
257 QuickSort(index, distance, k);
258 for (int i = 0; i < k; i++) {
259 small_value[i] = distance[index[i]];
260 }
261
262 for (int i = k; i < dim; i++) {
263 float max_value = small_value[k - 1];
264 if (distance[i] >= max_value) {
265 continue;
266 }
267 int locate_index = -1;
268 if (distance[i] < small_value[0]) {
269 locate_index = 0;
270 } else {
271 for (int j = 0; j < k - 1; j++) {
272 if (distance[i] >= small_value[j] &&
273 distance[i] <= small_value[j + 1]) {
274 locate_index = j + 1;
275 break;
276 } // if
277 } // for
278 } // else
279 if (locate_index == -1) {
280 return false;
281 }
282 for (int j = k - 2; j >= locate_index; j--) {
283 small_value[j + 1] = small_value[j];
284 index[j + 1] = index[j];
285 }
286 small_value[locate_index] = distance[i];
287 index[locate_index] = i;
288 }
289 return true;
290}

◆ gaussian()

template<typename Dtype >
Dtype apollo::perception::camera::gaussian ( Dtype  x,
Dtype  mu,
Dtype  sigma 
)
inline

在文件 math_functions.h30 行定义.

30 {
31 return static_cast<Dtype>(
32 std::exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
33}

◆ GenCorners()

template<typename T >
void apollo::perception::camera::GenCorners ( h,
w,
l,
T *  x_cor,
T *  y_cor,
T *  z_cor 
)

在文件 twod_threed_util.h111 行定义.

111 {
112 T half_w = static_cast<T>(w * 0.5f);
113 T half_l = static_cast<T>(l * 0.5f);
114 y_cor[0] = y_cor[1] = y_cor[2] = y_cor[3] = (T)0;
115 y_cor[4] = y_cor[5] = y_cor[6] = y_cor[7] = -h;
116 x_cor[0] = x_cor[4] = half_l;
117 z_cor[0] = z_cor[4] = half_w;
118 x_cor[1] = x_cor[5] = half_l;
119 z_cor[1] = z_cor[5] = -half_w;
120 x_cor[2] = x_cor[6] = -half_l;
121 z_cor[2] = z_cor[6] = -half_w;
122 x_cor[3] = x_cor[7] = -half_l;
123 z_cor[3] = z_cor[7] = half_w;
124}

◆ GenRotMatrix()

template<typename T >
void apollo::perception::camera::GenRotMatrix ( const T &  ry,
T *  rot 
)

在文件 twod_threed_util.h101 行定义.

101 {
102 rot[0] = static_cast<T>(cos(ry));
103 rot[2] = static_cast<T>(sin(ry));
104 rot[4] = static_cast<T>(1.0f);
105 rot[6] = static_cast<T>(-sin(ry));
106 rot[8] = static_cast<T>(cos(ry));
107 rot[1] = rot[3] = rot[5] = rot[7] = static_cast<T>(0);
108}

◆ get_area_id()

int apollo::perception::camera::get_area_id ( float  visible_ratios[4])

calculate the area id based on the visible ratios

参数
visible_ratiosvisible ratios
返回
int area_id

在文件 postprocess.cc380 行定义.

380 {
381 int area_id = 0;
382 int max_face = 0;
383 for (int i = 1; i < 4; i++) {
384 if (visible_ratios[i] > visible_ratios[max_face]) {
385 max_face = i;
386 }
387 }
388 int left_face = (max_face + 1) % 4;
389 int right_face = (max_face + 3) % 4;
390 const float eps = 1e-3f;
391 float max_ratio = visible_ratios[max_face];
392 float left_ratio = visible_ratios[left_face];
393 float right_ratio = visible_ratios[right_face];
394 memset(visible_ratios, 0, 4 * sizeof(visible_ratios[0]));
395 if (left_ratio < eps && right_ratio < eps) {
396 area_id = (max_face * 2 + 1);
397 visible_ratios[max_face] = 1.f;
398 } else if (left_ratio > right_ratio) {
399 area_id = (max_face * 2 + 2);
400 auto &&sum_ratio = left_ratio + max_ratio;
401 visible_ratios[max_face] = max_ratio / sum_ratio;
402 visible_ratios[left_face] = left_ratio / sum_ratio;
403 } else {
404 area_id = (max_face * 2);
405 if (area_id == 0) {
406 area_id = 8;
407 }
408 auto &&sum_ratio = right_ratio + max_ratio;
409 visible_ratios[max_face] = max_ratio / sum_ratio;
410 visible_ratios[right_face] = right_ratio / sum_ratio;
411 }
412 return area_id;
413}

◆ get_bbox_size()

float apollo::perception::camera::get_bbox_size ( const NormalizedBBox bbox)

在文件 postprocess.cc43 行定义.

43 {
44 if (bbox.xmax < bbox.xmin || bbox.ymax < bbox.ymin) {
45 // If bbox is invalid (e.g. xmax < xmin or ymax < ymin), return 0.
46 return 0;
47 } else {
48 if (bbox.size >= 0) {
49 return bbox.size;
50 } else {
51 float width = bbox.xmax - bbox.xmin;
52 float height = bbox.ymax - bbox.ymin;
53 return width * height;
54 }
55 }
56}

◆ get_cpu_data()

const float * apollo::perception::camera::get_cpu_data ( bool  flag,
const base::Blob< float > &  blob 
)

在文件 postprocess.cc415 行定义.

415 {
416 return flag ? blob.cpu_data() : nullptr;
417}
const Dtype * cpu_data() const
Definition blob.cc:137

◆ get_gpu_data()

const float * apollo::perception::camera::get_gpu_data ( bool  flag,
const base::Blob< float > &  blob 
)

Get the gpu data object

参数
flagflag to get the gpu data object
blobblob to get the gpu data object
返回
const float* the gpu data object

◆ get_intersect_bbox()

void apollo::perception::camera::get_intersect_bbox ( const NormalizedBBox bbox1,
const NormalizedBBox bbox2,
NormalizedBBox intersect_bbox 
)

Get the intersect bbox object

参数
bbox1[in] first bbox
bbox2[in] second bbox
intersect_bbox[out] intersect bbox

在文件 postprocess.cc25 行定义.

27 {
28 if (bbox2.xmin > bbox1.xmax || bbox2.xmax < bbox1.xmin ||
29 bbox2.ymin > bbox1.ymax || bbox2.ymax < bbox1.ymin) {
30 // Return [0, 0, 0, 0] if there is no intersection.
31 intersect_bbox->xmin = 0;
32 intersect_bbox->ymin = 0;
33 intersect_bbox->xmax = 0;
34 intersect_bbox->ymax = 0;
35 } else {
36 intersect_bbox->xmin = std::max(bbox1.xmin, bbox2.xmin);
37 intersect_bbox->ymin = std::max(bbox1.ymin, bbox2.ymin);
38 intersect_bbox->xmax = std::min(bbox1.xmax, bbox2.xmax);
39 intersect_bbox->ymax = std::min(bbox1.ymax, bbox2.ymax);
40 }
41}

◆ get_jaccard_overlap()

float apollo::perception::camera::get_jaccard_overlap ( const NormalizedBBox bbox1,
const NormalizedBBox bbox2 
)

Get the jaccard overlap object

参数
bbox1[in] first bbox
bbox2[in] second bbox
返回
float jaccard overlap

在文件 postprocess.cc58 行定义.

59 {
60 NormalizedBBox intersect_bbox;
61 get_intersect_bbox(bbox1, bbox2, &intersect_bbox);
62 float intersect_width = 0.f;
63 float intersect_height = 0.f;
64 intersect_width = intersect_bbox.xmax - intersect_bbox.xmin;
65 intersect_height = intersect_bbox.ymax - intersect_bbox.ymin;
66
67 if (intersect_width > 0 && intersect_height > 0) {
68 float intersect_size = intersect_width * intersect_height;
69 float bbox1_size = get_bbox_size(bbox1);
70 float bbox2_size = get_bbox_size(bbox2);
71 return intersect_size / (bbox1_size + bbox2_size - intersect_size);
72 } else {
73 return 0.;
74 }
75}
float get_bbox_size(const NormalizedBBox &bbox)
void get_intersect_bbox(const NormalizedBBox &bbox1, const NormalizedBBox &bbox2, NormalizedBBox *intersect_bbox)
Get the intersect bbox object

◆ get_max_score_index()

void apollo::perception::camera::get_max_score_index ( const std::vector< float > &  scores,
const float  threshold,
const int  top_k,
std::vector< std::pair< float, int > > *  score_index_vec 
)

Get the max score index object

参数
scoresthe scores array
thresholdthreshold value
top_ktop k
score_index_vecoutput index array

在文件 postprocess.cc77 行定义.

79 {
80 // Generate index score pairs.
81 for (int i = 0; i < static_cast<int>(scores.size()); ++i) {
82 if (scores[i] > threshold) {
83 score_index_vec->push_back(std::make_pair(scores[i], i));
84 }
85 }
86
87 // Sort the score pair according to the scores in descending order
88 std::stable_sort(score_index_vec->begin(), score_index_vec->end(),
89 sort_score_pair_descend<int>);
90
91 // Keep top_k scores if needed.
92 if (top_k > -1 && top_k < static_cast<int>(score_index_vec->size())) {
93 score_index_vec->resize(top_k);
94 }
95}

◆ get_objects_cpu()

void apollo::perception::camera::get_objects_cpu ( const YoloBlobs yolo_blobs,
const cudaStream_t &  stream,
const std::vector< base::ObjectSubType > &  types,
const NMSParam nms,
const yolo::ModelParam model_param,
float  light_vis_conf_threshold,
float  light_swt_conf_threshold,
base::Blob< bool > *  overlapped,
base::Blob< int > *  idx_sm,
std::vector< base::ObjectPtr > *  objects 
)

Get the objects cpu object

参数
yolo_blobsYOLO blobs
streamCUDA stream
typesobject types
nmsnms params
model_parammodel params
light_vis_conf_thresholdlight vis conf threshold
light_swt_conf_thresholdlight swt conf threshold
overlappedoverlapped blob
idx_smidx sm blob
objectsobject blob

在文件 postprocess.cc419 行定义.

425 {
426 std::map<base::ObjectSubType, std::vector<int>> indices;
427 std::map<base::ObjectSubType, std::vector<float>> conf_scores;
428 int num_kept = 0;
429 int num_classes = types.size();
430 num_kept = get_objects_gpu(yolo_blobs, stream, types, nms, model_param,
431 light_vis_conf_threshold, light_swt_conf_threshold,
432 overlapped, idx_sm, indices, conf_scores);
433 objects->clear();
434
435 if (num_kept == 0) {
436 return;
437 }
438
439 objects->reserve(num_kept + static_cast<int>(objects->size()));
440 const float *cpu_box_data = yolo_blobs.res_box_blob->cpu_data();
441
442 ObjectMaintainer maintainer;
443 for (auto it = indices.begin(); it != indices.end(); ++it) {
444 base::ObjectSubType label = it->first;
445 if (conf_scores.find(label) == conf_scores.end()) {
446 // Something bad happened if there are no predictions for current label.
447 continue;
448 }
449 const std::vector<float> &scores = conf_scores.find(label)->second;
450 std::vector<int> &indice = it->second;
451 for (size_t j = 0; j < indice.size(); ++j) {
452 int idx = indice[j];
453 const float *bbox = cpu_box_data + idx * kBoxBlockSize;
454 if (scores[idx] < model_param.confidence_threshold()) {
455 continue;
456 }
457
458 base::ObjectPtr obj = nullptr;
459 obj.reset(new base::Object);
460 obj->type = base::kSubType2TypeMap.at(label);
461 obj->sub_type = label;
462 obj->type_probs.assign(
463 static_cast<int>(base::ObjectType::MAX_OBJECT_TYPE), 0);
464 obj->sub_type_probs.assign(
465 static_cast<int>(base::ObjectSubType::MAX_OBJECT_TYPE), 0);
466 float total = 1e-5;
467 for (int k = 0; k < num_classes; ++k) {
468 auto &vis_type_k = types[k];
469 auto &obj_type_k = base::kSubType2TypeMap.at(vis_type_k);
470 auto &conf_score = conf_scores[vis_type_k][idx];
471 obj->type_probs[static_cast<int>(obj_type_k)] += conf_score;
472 obj->sub_type_probs[static_cast<int>(vis_type_k)] = conf_score;
473 total += conf_score;
474 }
475 obj->confidence = obj->type_probs[static_cast<int>(obj->type)];
476 for (size_t k = 0; k < obj->type_probs.size(); ++k) {
477 obj->type_probs[k] /= total;
478 }
479 fill_base(obj, bbox);
480 fill_bbox3d(model_param.with_box3d(), obj, bbox + 4);
481 fill_frbox(model_param.with_frbox(), obj, bbox + 8);
482 fill_lights(model_param.with_lights(), obj, bbox + 16);
483 fill_ratios(model_param.with_ratios(), obj, bbox + 22);
484 fill_area_id(model_param.num_areas() > 0, obj, bbox + 30);
485
486 // todo: maintainer just found?
487 if (maintainer.Add(idx, obj)) {
488 objects->push_back(obj);
489 }
490 }
491 }
492}
int get_objects_gpu(const YoloBlobs &yolo_blobs, const cudaStream_t &stream, const std::vector< base::ObjectSubType > &types, const NMSParam &nms, const yolo::ModelParam &model_param, float light_vis_conf_threshold, float light_swt_conf_threshold, base::Blob< bool > *overlapped, base::Blob< int > *idx_sm, const std::map< base::ObjectSubType, std::vector< int > > &indices, const std::map< base::ObjectSubType, std::vector< float > > &conf_scores)
Get the objects gpu object
void fill_base(base::ObjectPtr obj, const float *bbox)
add bbox value to object
void fill_ratios(bool with_ratios, base::ObjectPtr obj, const float *bbox)
add ratio value to object
void fill_frbox(bool with_frbox, base::ObjectPtr obj, const float *bbox)
add car front and backward bbox value to object
void fill_area_id(bool with_flag, base::ObjectPtr obj, const float *data)
add area id value to object
void fill_bbox3d(bool with_box3d, base::ObjectPtr obj, const float *bbox)
add alpha h w l to object
void fill_lights(bool with_lights, base::ObjectPtr obj, const float *bbox)
add car lights value to object
std::shared_ptr< base::Blob< float > > res_box_blob

◆ get_objects_gpu()

int apollo::perception::camera::get_objects_gpu ( const YoloBlobs yolo_blobs,
const cudaStream_t &  stream,
const std::vector< base::ObjectSubType > &  types,
const NMSParam nms,
const yolo::ModelParam model_param,
float  light_vis_conf_threshold,
float  light_swt_conf_threshold,
base::Blob< bool > *  overlapped,
base::Blob< int > *  idx_sm,
const std::map< base::ObjectSubType, std::vector< int > > &  indices,
const std::map< base::ObjectSubType, std::vector< float > > &  conf_scores 
)

Get the objects gpu object

参数
yolo_blobsYOLO blobs
streamStream to use
typesType of object
nmsNMS type
model_paramModel's parameter
light_vis_conf_thresholdLight vis confidence threshold
light_swt_conf_thresholdLight swt confidence threshold
overlappedOverlapped objects
idx_smIndices of objects in blob
indicesIndices of objects in blob
conf_scoresConfidence scores of objects
返回
int

◆ GetBboxFromPts()

template<typename T >
void apollo::perception::camera::GetBboxFromPts ( const T *  pts,
const int &  n,
T *  bbox 
)

在文件 twod_threed_util.h147 行定义.

147 {
148 bbox[0] = bbox[2] = pts[0];
149 bbox[1] = bbox[3] = pts[1];
150 int i2 = 2;
151 for (int i = 1; i < n; ++i) {
152 T x = pts[i2];
153 T y = pts[i2 + 1];
154 bbox[0] = std::min(bbox[0], x);
155 bbox[1] = std::min(bbox[1], y);
156 bbox[2] = std::max(bbox[2], x);
157 bbox[3] = std::max(bbox[3], y);
158 i2 += 2;
159 }
160}

◆ GetBlobNames3DYolox()

std::vector< std::string > apollo::perception::camera::GetBlobNames3DYolox ( const google::protobuf::RepeatedPtrField< common::ModelBlob > &  model_blobs)

在文件 yolox3d_obstacle_detector.cc67 行定义.

68 {
69 std::vector<std::string> blob_names;
70 for (const auto &blob : model_blobs) {
71 blob_names.push_back(blob.name());
72 }
73 return blob_names;
74}

◆ GetCaddnObjects()

void apollo::perception::camera::GetCaddnObjects ( std::vector< base::ObjectPtr > *  objects,
const caddn::ModelParam model_param,
const std::vector< base::ObjectSubType > &  types,
const base::BlobPtr< float > &  boxes,
const base::BlobPtr< float > &  labels,
const base::BlobPtr< float > &  scores 
)

Get the Caddn Objects objects from Blob

参数
objectsThe objects container
model_paramThe Caddn model param
typesThe object types
boxesThe boxes container
labelsThe labels container
scoresThe scores container

在文件 postprocess.cc25 行定义.

30 {
31 objects->clear();
32 const float *boxes_data = boxes->cpu_data();
33 const float *labels_data = labels->cpu_data();
34 const float *scores_data = scores->cpu_data();
35
36 int len_pred = 7;
37 for (int i = 0; i < labels->num(); ++i) {
38 const float *bbox = boxes_data + i * len_pred;
39 float score = *(scores_data + i);
40 if (score < model_param.score_threshold()) {
41 continue;
42 }
43
44 float label = *(labels_data + i);
45 base::ObjectPtr obj = nullptr;
46 obj.reset(new base::Object);
47 obj->sub_type = GetSubtype(label, types);
48 obj->type = base::kSubType2TypeMap.at(obj->sub_type);
49 obj->type_probs.assign(static_cast<int>(base::ObjectType::MAX_OBJECT_TYPE),
50 0);
51 obj->sub_type_probs.assign(
52 static_cast<int>(base::ObjectSubType::MAX_OBJECT_TYPE), 0);
53 obj->type_probs[static_cast<int>(obj->type)] = score;
54 obj->sub_type_probs[static_cast<int>(obj->sub_type)] = score;
55 obj->confidence = score;
56
57 // todo(zero): Need to be converted to camera coordinates and
58 // converted to KITTI coordinates
59 Eigen::Matrix<float, 3, 4> velo_to_cam;
60 velo_to_cam << 0.00753374, -0.9999714, -0.0006166, -0.00406977, 0.01480249,
61 0.00072807, -0.9998902, -0.07631618, 0.9998621, 0.00752379, 0.01480755,
62 -0.2717806;
63
64 Eigen::Matrix<float, 3, 3> R;
65 R << 0.9999239, 0.00983776, -0.00744505, -0.0098698, 0.9999421, -0.00427846,
66 0.00740253, 0.00435161, 0.9999631;
67
68 std::vector<float> test_result(7);
69 Bbox3dLidar2Camera(velo_to_cam, R, bbox, &test_result);
70
71 FillCaddnBbox3d(obj, test_result.data());
72
73 objects->push_back(obj);
74 }
75}
std::shared_ptr< Object > ObjectPtr
Definition object.h:127

◆ GetDxDzForCenterFromGroundLineSeg()

template<typename T >
void apollo::perception::camera::GetDxDzForCenterFromGroundLineSeg ( const LineSegment2D< T > &  ls,
const T *  plane,
const T *  pts_c,
const T *  k_mat,
int  width,
int  height,
ratio_x_over_z,
T *  dx_dz,
bool  check_lowerbound = true 
)

在文件 twod_threed_util.h277 行定义.

281 {
282 const T Z_RESOLUTION = static_cast<T>(1e-1);
283 const T Z_UNSTABLE_RATIO = static_cast<T>(0.3f);
284
285 dx_dz[0] = dx_dz[1] = (T)0;
286 ACHECK(ls.pt_start[0] < ls.pt_end[0]);
287 if (!CheckXY(ls.pt_start[0], ls.pt_start[1], width, height) ||
288 !CheckXY(ls.pt_end[0], ls.pt_end[1], width, height)) {
289 return;
290 }
291 T pt_of_line_seg_l[3] = {0};
292 T pt_of_line_seg_r[3] = {0};
293 bool is_front_l = algorithm::IBackprojectPlaneIntersectionCanonical(
294 ls.pt_start, k_mat, plane, pt_of_line_seg_l);
295 bool is_front_r = algorithm::IBackprojectPlaneIntersectionCanonical(
296 ls.pt_end, k_mat, plane, pt_of_line_seg_r);
297 if (!is_front_l || !is_front_r) {
298 return;
299 }
300 ADEBUG << "l&r on-ground points: " << pt_of_line_seg_l[0] << ", "
301 << pt_of_line_seg_l[1] << ", " << pt_of_line_seg_l[2] << " | "
302 << pt_of_line_seg_r[0] << ", " << pt_of_line_seg_r[1] << ", "
303 << pt_of_line_seg_r[2];
304
305 // get transform
306 T rot[9] = {0};
307 T t[3] = {0};
308 T pos[3] = {pt_of_line_seg_l[0], pt_of_line_seg_l[1], pt_of_line_seg_l[2]};
309 T v[3] = {pt_of_line_seg_r[0] - pt_of_line_seg_l[0],
310 pt_of_line_seg_r[1] - pt_of_line_seg_l[1],
311 pt_of_line_seg_r[2] - pt_of_line_seg_l[2]};
312 T ry = static_cast<T>(-atan2(v[2], v[0]));
313 GenRotMatrix(ry, rot);
314 algorithm::ITranspose3x3(rot);
315 algorithm::IScale3(pos, (T)-1);
316 algorithm::IMultAx3x3(rot, pos, t);
317 ADEBUG << "ry: " << ry;
318
319 T l[3] = {0};
320 T pt1[3] = {0};
321 T pt2[3] = {ratio_x_over_z, (T)0, (T)1};
322 T pt1_local[3] = {0};
323 T pt2_local[3] = {0};
324
325 // transform to local birdview coordinates
326 std::pair<T, T> range;
327 range.first = 0;
328 range.second = algorithm::ISqrt(
329 algorithm::ISqr(v[0]) + algorithm::ISqr(v[2]));
330 T pts_local[12] = {0};
331 algorithm::IProjectThroughExtrinsic(rot, t, pts_c, pts_local);
332 algorithm::IProjectThroughExtrinsic(rot, t, pts_c + 3, pts_local + 3);
333 algorithm::IProjectThroughExtrinsic(rot, t, pts_c + 6, pts_local + 6);
334 algorithm::IProjectThroughExtrinsic(rot, t, pts_c + 9, pts_local + 9);
335
336 algorithm::IProjectThroughExtrinsic(rot, t, pt1, pt1_local);
337 algorithm::IProjectThroughExtrinsic(rot, t, pt2, pt2_local);
338 T x[2] = {pt1_local[0], pt1_local[2]};
339 T xp[2] = {pt2_local[0], pt2_local[2]};
340 algorithm::ILineFit2d(x, xp, l);
341
342 T zs[4] = {pts_local[2], pts_local[5], pts_local[8], pts_local[11]};
343 T z_offset = static_cast<T>(0);
344 bool all_positive = zs[0] > 0.0f && zs[1] > 0.f && zs[2] > 0.f && zs[3] > 0.f;
345 if (all_positive) {
346 z_offset = std::min(zs[0], std::min(zs[1], std::min(zs[2], zs[3])));
347 } else {
348 z_offset = std::max(zs[0], std::max(zs[1], std::max(zs[2], zs[3])));
349 T xs[4] = {pts_local[0], pts_local[3], pts_local[6], pts_local[9]};
350 // 1 -> 2
351 UpdateOffsetZ(xs[0], zs[0], xs[1], zs[1], range, &z_offset);
352 // 2 -> 3
353 UpdateOffsetZ(xs[1], zs[1], xs[2], zs[2], range, &z_offset);
354 // 3 -> 4
355 UpdateOffsetZ(xs[2], zs[2], xs[3], zs[3], range, &z_offset);
356 // 4 -> 1
357 UpdateOffsetZ(xs[3], zs[3], xs[0], zs[0], range, &z_offset);
358 }
359 if (z_offset < Z_RESOLUTION && z_offset > -Z_RESOLUTION) {
360 return;
361 }
362
363 // judge & convert back to camera coordinates
364 if (z_offset > static_cast<T>(0.0f) && check_lowerbound) {
365 return;
366 }
367
368 T center_c[3] = {0};
369 center_c[0] = (pts_c[0] + pts_c[3] + pts_c[6] + pts_c[9]) / 4;
370 center_c[2] = (pts_c[2] + pts_c[5] + pts_c[8] + pts_c[11]) / 4;
371 T z_avg = center_c[2];
372
373 T dz_local = -z_offset;
374 T dx_local =
375 -l[1] * dz_local * algorithm::IRec(l[0]); /*enforce to be along the ray*/
376
377 T center_local[3] = {0};
378 algorithm::IProjectThroughExtrinsic(rot, t, center_c, center_local);
379 center_local[0] += dx_local;
380 center_local[1] = 0;
381 center_local[2] += dz_local;
382 T center_local_to_c[3] = {0};
383 algorithm::ISub3(t, center_local);
384 algorithm::IMultAtx3x3(rot, center_local, center_local_to_c);
385 dx_dz[0] = center_local_to_c[0] - center_c[0];
386 dx_dz[1] = center_local_to_c[2] - center_c[2];
387
388 T dz_max = z_avg * Z_UNSTABLE_RATIO;
389 if (z_offset > static_cast<T>(0.0f) && std::abs(dx_dz[1]) > dz_max) {
390 dx_dz[0] = dx_dz[1] = 0;
391 }
392}
#define ADEBUG
Definition log.h:41
void GenRotMatrix(const T &ry, T *rot)
bool CheckXY(const T &x, const T &y, int width, int height)
void UpdateOffsetZ(T x_start, T z_start, T x_end, T z_end, const std::pair< T, T > &range, T *z_offset)

◆ GetFileListFromFile()

bool apollo::perception::camera::GetFileListFromFile ( const std::string &  file_name,
std::vector< std::string > *  file_list 
)

Get the File List From File object

参数
file_nameA file containing all filenames
file_listArray of output filenames
返回
true success
false fail

在文件 util.cc64 行定义.

65 {
66 std::ifstream in(file_name.c_str());
67
68 if (!in) {
69 AERROR << "Failed to open file: " << file_name;
70 return false;
71 }
72
73 std::string line;
74 while (std::getline(in, line)) {
75 if (!line.empty()) {
76 file_list->push_back(line);
77 }
78 }
79
80 in.close();
81 return true;
82}

◆ GetFileListFromPath()

bool apollo::perception::camera::GetFileListFromPath ( const std::string &  file_path,
std::vector< std::string > *  file_list 
)

Get the File List From Path object

参数
file_pathA file path containing all filenames
file_listArray of output filenames
返回
true success
false fail

在文件 util.cc58 行定义.

59 {
60 // todo(zero): need complete
61 return true;
62}

◆ GetGround3FromPitchHeight()

void apollo::perception::camera::GetGround3FromPitchHeight ( const std::vector< float > &  k_mat,
const float &  baseline,
const float &  pitch,
const float &  cam_height,
std::vector< float > *  ground3 
)

在文件 camera_ground_plane.cc97 行定义.

100 {
101 CHECK_EQ(k_mat.size(), 9U);
102 CHECK_GT(baseline, 0.0f);
103 CHECK_GT(cam_height, 0.0f);
104 CHECK_NOTNULL(ground3);
105 CHECK_EQ(ground3->size(), 3U);
106 float sin_pitch = static_cast<float>(sin(pitch));
107 float cos_pitch = static_cast<float>(cos(pitch));
108 std::vector<float> ground4 = {0, cos_pitch, -sin_pitch, -cam_height};
109 ConvertGround4ToGround3(baseline, k_mat, ground4, ground3);
110}

◆ GetGroundPlanePitchHeight()

void apollo::perception::camera::GetGroundPlanePitchHeight ( const float &  baseline,
const std::vector< float > &  k_mat,
const std::vector< float > &  ground3,
float *  pitch,
float *  cam_height 
)

在文件 camera_ground_plane.cc77 行定义.

80 {
81 CHECK_GT(baseline, 0.0f);
82 CHECK_EQ(k_mat.size(), 9U);
83 CHECK_EQ(ground3.size(), 3U);
84 CHECK_NOTNULL(pitch);
85 CHECK_NOTNULL(cam_height);
86 std::vector<float> ground4(4, 0.0f);
87 ConvertGround3ToGround4(baseline, k_mat, ground3, &ground4);
88 if (ground4[3] > 0.0f) {
89 algorithm::IScale4(ground4.data(), -1.0f);
90 }
91 *cam_height = -ground4[3];
92 double cos_pitch = ground4[1];
93 double sin_pitch = -ground4[2];
94 *pitch = static_cast<float>(atan2(sin_pitch, cos_pitch));
95}
void ConvertGround3ToGround4(const float &baseline, const std::vector< float > &k_mat, const std::vector< float > &ground3, std::vector< float > *ground4)

◆ GetImage()

cv::Mat apollo::perception::camera::GetImage ( const std::string &  path,
bool  to_rgb 
)

在文件 camera_preprocess_general_util.cc26 行定义.

26 {
27 cv::Mat img = cv::imread(path);
28
29 if (!img.data) {
30 throw std::runtime_error("Failed to read image: " + path);
31 }
32
33 if (to_rgb && img.channels() == 3) {
34 cv::cvtColor(img, img, cv::COLOR_BGR2RGB);
35 }
36 return img;
37}

◆ GetJaccardIndex()

template<typename T >
T apollo::perception::camera::GetJaccardIndex ( const T *  bbox_ref,
const T &  x_min,
const T &  y_min,
const T &  x_max,
const T &  y_max 
)

在文件 twod_threed_util.h86 行定义.

87 {
88 T overlap_x = std::min(bbox_ref[2], x_max) - std::max(bbox_ref[0], x_min);
89 T overlap_y = std::min(bbox_ref[3], y_max) - std::max(bbox_ref[1], y_min);
90 if (overlap_y <= (T)0 || overlap_x <= (T)0) {
91 return (T)0;
92 }
93 T inter_area = overlap_x * overlap_y;
94 T union_area = (y_max - y_min) * (x_max - x_min) +
95 (bbox_ref[3] - bbox_ref[1]) * (bbox_ref[2] - bbox_ref[0]) -
96 inter_area;
97 return inter_area * algorithm::IRec(union_area);
98}

◆ GetMinIndexVec()

template<typename T >
int apollo::perception::camera::GetMinIndexVec ( const T *  vec,
const int &  n 
)

在文件 twod_threed_util.h163 行定义.

163 {
164 CHECK_GT(n, 0);
165 int index = 0;
166 T min_val = vec[0];
167 for (int i = 1; i < n; ++i) {
168 if (vec[i] < min_val) {
169 min_val = vec[i];
170 index = i;
171 }
172 }
173 return index;
174}

◆ GetObjects()

void apollo::perception::camera::GetObjects ( const base::BlobPtr< float > &  box3ds,
const base::BlobPtr< float > &  labels,
const base::BlobPtr< float > &  scores,
const std::vector< base::ObjectSubType > &  types,
float  score_threshold,
std::vector< base::ObjectPtr > *  objects 
)

Get the Objects objects from blob

参数
box3dsThe input box 3ds blob
labelsThe input labels blob
scoresThe input scores blob
typesThe input types blob
score_thresholdThe threshold for score to be considered
objectsThe output objects blob

在文件 postprocess.cc35 行定义.

39 {
40 const auto bbox_ptr = box3ds->cpu_data();
41 const auto label_ptr = labels->cpu_data();
42 const auto score_ptr = scores->cpu_data();
43
44 int feature_size = box3ds->shape(1);
45 objects->clear();
46 for (int i = 0; i < scores->count(); ++i) {
47 float score = score_ptr[i];
48 if (score < score_threshold) {
49 continue;
50 }
51
53 obj.reset(new base::Object());
54
55 obj->sub_type = GetSubtype(label_ptr[i], types);
56 obj->type = base::kSubType2TypeMap.at(obj->sub_type);
57 obj->type_probs.assign(static_cast<int>(base::ObjectType::MAX_OBJECT_TYPE),
58 0);
59 obj->sub_type_probs.assign(
60 static_cast<int>(base::ObjectSubType::MAX_OBJECT_TYPE), 0);
61 obj->type_probs[static_cast<int>(obj->type)] = score;
62 obj->sub_type_probs[static_cast<int>(obj->sub_type)] = score;
63 obj->confidence = score;
64
65 FillBBox3d(bbox_ptr + i * feature_size, obj);
66
67 objects->push_back(obj);
68 }
69}

◆ GetObjectsCpu()

void apollo::perception::camera::GetObjectsCpu ( const std::shared_ptr< base::Blob< float > > &  output_blob,
const std::vector< base::ObjectSubType > &  types,
const smoke::ModelParam model_param,
std::vector< base::ObjectPtr > *  objects,
int  width,
int  height 
)

在文件 postprocess.cc108 行定义.

112 {
113 const float* detect_result = output_blob->cpu_data();
114 objects->clear();
115 auto shape = output_blob->shape();
116
117 int len_pred = shape[1];
118 int total = shape[0] * shape[1];
119 int step = 0;
120 while (step < total) {
121 const float* bbox = detect_result + step;
122 step += len_pred;
123 float score = bbox[13];
124 if (score < model_param.confidence_threshold()) {
125 continue;
126 }
127
128 base::ObjectPtr obj = std::make_shared<base::Object>();
129 int label = static_cast<int>(bbox[0]);
130 obj->sub_type = GetSubtype(label, types);
131 obj->type = base::kSubType2TypeMap.at(obj->sub_type);
132 obj->type_probs.assign(
133 static_cast<int>(base::ObjectType::MAX_OBJECT_TYPE), 0);
134 obj->sub_type_probs.assign(
135 static_cast<int>(base::ObjectSubType::MAX_OBJECT_TYPE), 0);
136 obj->type_probs[static_cast<int>(obj->type)] = score;
137 obj->sub_type_probs[static_cast<int>(obj->sub_type)] = score;
138 obj->confidence = score;
139
140 FillBBox(obj, bbox, width, height);
141 FillBBox3d(obj, bbox);
142 objects->push_back(obj);
143 }
144}

◆ GetPolyValue()

template<typename T = float>
T apollo::perception::camera::GetPolyValue ( a,
b,
c,
d,
x 
)

在文件 darkSCNN_lane_postprocessor.cc66 行定义.

66 {
67 T y = d;
68 T v = x;
69 y += (c * v);
70 v *= x;
71 y += (b * v);
72 v *= x;
73 y += (a * v);
74 return y;
75}

◆ GetSceneFlowLabel()

PointSemanticLabel apollo::perception::camera::GetSceneFlowLabel ( uint8_t  value)
inline

在文件 utils.h47 行定义.

47 {
48 return static_cast<PointSemanticLabel>(value >> 4);
49}

◆ GetScoreViaRotDimensionCenter()

template<typename T >
T apollo::perception::camera::GetScoreViaRotDimensionCenter ( const T *  k_mat,
int  width,
int  height,
const T *  bbox,
const T *  rot,
const T *  hwl,
const T *  location,
const bool &  check_truncation,
T *  bbox_res = nullptr,
T *  bbox_near = nullptr 
)

在文件 twod_threed_util.h177 行定义.

180 {
181 T h = hwl[0];
182 T w = hwl[1];
183 T l = hwl[2];
184 T x_corners[8] = {0};
185 T y_corners[8] = {0};
186 T z_corners[8] = {0};
187 GenCorners(h, w, l, x_corners, y_corners, z_corners);
188
189 T x_min = std::numeric_limits<float>::max();
190 T x_max = -std::numeric_limits<float>::max();
191 T y_min = std::numeric_limits<float>::max();
192 T y_max = -std::numeric_limits<float>::max();
193 T x_proj[3];
194 T x_box[3];
195 T pts_proj[16];
196 for (int i = 0; i < 8; ++i) {
197 x_box[0] = x_corners[i];
198 x_box[1] = y_corners[i];
199 x_box[2] = z_corners[i];
200 algorithm::IProjectThroughKRt(k_mat, rot, location, x_box, x_proj);
201 x_proj[0] *= algorithm::IRec(x_proj[2]);
202 x_proj[1] *= algorithm::IRec(x_proj[2]);
203
204 if (bbox_near != nullptr) {
205 int i2 = i * 2;
206 pts_proj[i2] = x_proj[0];
207 pts_proj[i2 + 1] = x_proj[1];
208 }
209 x_min = std::min(x_min, x_proj[0]);
210 x_max = std::max(x_max, x_proj[0]);
211 y_min = std::min(y_min, x_proj[1]);
212 y_max = std::max(y_max, x_proj[1]);
213 if (check_truncation) {
214 x_min = std::min(std::max(x_min, (T)0), (T)(width - 1));
215 x_max = std::min(std::max(x_max, (T)0), (T)(width - 1));
216 y_min = std::min(std::max(y_min, (T)0), (T)(height - 1));
217 y_max = std::min(std::max(y_max, (T)0), (T)(height - 1));
218 }
219 }
220 if (bbox_res != nullptr) {
221 bbox_res[0] = x_min;
222 bbox_res[1] = y_min;
223 bbox_res[2] = x_max;
224 bbox_res[3] = y_max;
225 }
226 if (bbox_near != nullptr) {
227 T bbox_front[4] = {0};
228 T bbox_rear[4] = {0};
229 std::swap(pts_proj[4], pts_proj[8]);
230 std::swap(pts_proj[5], pts_proj[9]);
231 std::swap(pts_proj[6], pts_proj[10]);
232 std::swap(pts_proj[7], pts_proj[11]);
233 GetBboxFromPts(pts_proj, 4, bbox_front);
234 GetBboxFromPts(pts_proj + 8, 4, bbox_rear);
235 if (bbox_rear[3] - bbox_rear[1] > bbox_front[3] - bbox_front[1]) {
236 memcpy(bbox_near, bbox_rear, sizeof(T) * 4);
237 } else {
238 memcpy(bbox_near, bbox_front, sizeof(T) * 4);
239 }
240 }
241 return GetJaccardIndex(bbox, x_min, y_min, x_max, y_max);
242}
T GetJaccardIndex(const T *bbox_ref, const T &x_min, const T &y_min, const T &x_max, const T &y_max)
void GetBboxFromPts(const T *pts, const int &n, T *bbox)

◆ GetSemanticLabel()

PointSemanticLabel apollo::perception::camera::GetSemanticLabel ( uint8_t  value)
inline

在文件 utils.h33 行定义.

33 {
34 return static_cast<PointSemanticLabel>(value & 15);
35}

◆ GetSharpAngle()

template<typename T >
T apollo::perception::camera::GetSharpAngle ( const T &  a,
const T &  b 
)
inline

在文件 twod_threed_util.h72 行定义.

72 {
73 /*a and b are in [-pi, pi)*/
74 const T pi = algorithm::Constant<T>::PI();
75 T angle = std::abs(a - b);
76 if (angle > pi) {
77 angle -= pi;
78 }
79 angle = std::min(angle, pi - angle);
80 return angle;
81}

◆ GetSubtype()

base::ObjectSubType apollo::perception::camera::GetSubtype ( int  cls,
const std::vector< base::ObjectSubType > &  types 
)

Get the Subtype

Get the Subtype objects from Blob

参数
clsInput class label
typesOutput type label
返回
base::ObjectSubType
参数
clsthe object container
typesthe object types
返回
base::ObjectSubType

在文件 postprocess.cc26 行定义.

27 {
28 if (cls < 0 || cls >= static_cast<int>(types.size())) {
29 return base::ObjectSubType::UNKNOWN;
30 }
31
32 return types[cls];
33}

◆ GetYawVelocityInfo()

void apollo::perception::camera::GetYawVelocityInfo ( const float &  time_diff,
const double  cam_coord_cur[3],
const double  cam_coord_pre[3],
const double  cam_coord_pre_pre[3],
float *  yaw_rate,
float *  velocity 
)

在文件 lane_based_calibrator.cc24 行定义.

27 {
28 assert(yaw_rate != nullptr);
29 assert(velocity != nullptr);
30 double time_diff_r = algorithm::IRec(static_cast<double>(time_diff));
31 double dist = algorithm::ISqrt(
32 algorithm::ISquaresumDiffU2(cam_coord_cur, cam_coord_pre));
33 *velocity = static_cast<float>(dist * time_diff_r);
34
35 double offset_cur[2] = {
36 cam_coord_cur[0] - cam_coord_pre[0],
37 cam_coord_cur[1] - cam_coord_pre[1],
38 };
39 double offset_pre[2] = {
40 cam_coord_pre[0] - cam_coord_pre_pre[0],
41 cam_coord_pre[1] - cam_coord_pre_pre[1],
42 };
43 double yaw_cur = atan2(offset_cur[1], offset_cur[0]);
44 double yaw_pre = atan2(offset_pre[1], offset_pre[0]);
45 double yaw_rate_db = (yaw_cur - yaw_pre) * time_diff_r;
46 *yaw_rate = static_cast<float>(yaw_rate_db);
47}

◆ GroundFittingCostFunc()

template<typename T >
void apollo::perception::camera::GroundFittingCostFunc ( const T *  p,
const T *  v,
const T *  d,
int  n,
int *  nr_inlier,
int *  inliers,
T *  cost,
error_tol 
)

在文件 camera_ground_plane.h179 行定义.

183 {
184 *cost = static_cast<T>(0.0f);
185 *nr_inlier = 0;
186 const T *refx = v;
187 const T *refp = d;
188 for (int i = 0; i < n; ++i) {
189 T d_proj = refx[0] * p[0] + p[1];
190 T proj_err = static_cast<T>(fabs(d_proj - refp[0]));
191 if (proj_err < error_tol) {
192 inliers[(*nr_inlier)++] = i;
193 *cost += proj_err;
194 }
195 ++refx;
196 ++refp;
197 }
198}

◆ GroundHypoGenFunc()

template<typename T >
void apollo::perception::camera::GroundHypoGenFunc ( const T *  v,
const T *  d,
T *  p 
)

在文件 camera_ground_plane.h168 行定义.

168 {
169 // disp = p0 * y + p1 -> l = {p0, -1, p1}
170 T x[2] = {v[0], d[0]};
171 T xp[2] = {v[1], d[1]};
172 T l[3] = {0};
173 algorithm::ILineFit2d(x, xp, l);
174 p[0] = -l[0] * algorithm::IRec(l[1]);
175 p[1] = -l[2] * algorithm::IRec(l[1]);
176}

◆ HWC2CHW()

std::vector< float > apollo::perception::camera::HWC2CHW ( const cv::Mat &  input_img)

在文件 camera_preprocess_general_util.cc69 行定义.

69 {
70 int channel = input_img.channels();
71 int width = input_img.cols;
72 int height = input_img.rows;
73
74 std::vector<cv::Mat> input_channels(channel);
75 cv::split(input_img, input_channels);
76
77 std::vector<float> result(channel * width * height);
78 auto data = result.data();
79 int channel_length = width * height;
80
81 for (int i = 0; i < channel; ++i) {
82 memcpy(data, input_channels[i].data, channel_length * sizeof(float));
83 data += channel_length;
84 }
85 return result;
86}

◆ ImagePoint2Camera()

bool apollo::perception::camera::ImagePoint2Camera ( const base::Point2DF img_point,
float  pitch_angle,
float  camera_ground_height,
const Eigen::Matrix3f &  intrinsic_params_inverse,
Eigen::Vector3d *  camera_point 
)

在文件 common_functions.cc203 行定义.

206 {
207 Eigen::MatrixXf pt_m(3, 1);
208 pt_m << img_point.x, img_point.y, 1;
209 const Eigen::MatrixXf& org_camera_point = intrinsic_params_inverse * pt_m;
210 //
211 float cos_pitch = static_cast<float>(cos(pitch_angle));
212 float sin_pitch = static_cast<float>(sin(pitch_angle));
213 Eigen::Matrix3f pitch_matrix;
214 pitch_matrix << 1, 0, 0, 0, cos_pitch, sin_pitch, 0, -sin_pitch, cos_pitch;
215 const Eigen::MatrixXf& rotate_point = pitch_matrix * org_camera_point;
216 if (fabs(rotate_point(1, 0)) < lane_eps_value) {
217 return false;
218 }
219 float scale = camera_ground_height / rotate_point(1, 0);
220 (*camera_point)(0) = scale * org_camera_point(0, 0);
221 (*camera_point)(1) = scale * org_camera_point(1, 0);
222 (*camera_point)(2) = scale * org_camera_point(2, 0);
223 return true;
224}

◆ imageRemap()

bool apollo::perception::camera::imageRemap ( const base::Image8U src_img,
base::Image8U dst_img,
const int  src_width,
const int  src_height,
const base::Blob< float > &  map_x,
const base::Blob< float > &  map_y 
)

在文件 image_data_operations.cc60 行定义.

63 {
64 return nppImageRemap(src_img, dst_img, src_width, src_height, map_x, map_y);
65}
bool nppImageRemap(const base::Image8U &src_img, base::Image8U *dst_img, const int src_width, const int src_height, const base::Blob< float > &map_x, const base::Blob< float > &map_y)

◆ imageToBlob()

bool apollo::perception::camera::imageToBlob ( const base::Image8U image,
base::Blob< uint8_t > *  blob 
)

在文件 image_data_operations.cc39 行定义.

39 {
40 return nppImageToBlob(image, blob);
41}
bool nppImageToBlob(const base::Image8U &image, base::Blob< uint8_t > *blob)

◆ imageToGray()

bool apollo::perception::camera::imageToGray ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height,
const float  coeffs[3] 
)

在文件 image_data_operations.cc43 行定义.

45 {
46 return nppImageToGray(src, dst, src_width, src_height, coeffs);
47}
bool nppImageToGray(const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height, const float coeffs[3])

◆ InitDataProvider()

bool apollo::perception::camera::InitDataProvider ( onboard::CameraFrame camera_frame)

在文件 offline_camera_detection.cc53 行定义.

53 {
54 DataProvider::InitOptions init_options;
55 init_options.sensor_name = FLAGS_camera_name;
56 init_options.image_height = FLAGS_height;
57 init_options.image_width = FLAGS_width;
58 init_options.device_id = FLAGS_gpu_id;
59
60 bool res = camera_frame->data_provider->Init(init_options);
61 return res;
62}

◆ IsCovered()

template<typename T >
bool apollo::perception::camera::IsCovered ( const base::Rect< T > &  rect1,
const base::Rect< T > &  rect2,
float  thresh 
)

在文件 util.h39 行定义.

40 {
41 base::RectF inter = rect1 & rect2;
42 return inter.Area() / rect1.Area() > thresh;
43}
Rect< float > RectF
Definition box.h:160

◆ IsCoveredHorizon()

template<typename T >
bool apollo::perception::camera::IsCoveredHorizon ( const base::Rect< T > &  rect1,
const base::Rect< T > &  rect2,
float  thresh 
)

在文件 util.h45 行定义.

46 {
47 base::RectF inter = rect1 & rect2;
48 if (inter.Area() > 0) {
49 return inter.width / rect1.width > thresh;
50 }
51 return false;
52}

◆ IsCoveredVertical()

template<typename T >
bool apollo::perception::camera::IsCoveredVertical ( const base::Rect< T > &  rect1,
const base::Rect< T > &  rect2,
float  thresh 
)

在文件 util.h54 行定义.

55 {
56 base::RectF inter = rect1 & rect2;
57 if (inter.Area() > 0) {
58 return inter.height / rect1.height > thresh;
59 }
60 return false;
61}

◆ IsSceneFlowLabelEqual()

bool apollo::perception::camera::IsSceneFlowLabelEqual ( PointSemanticLabel  label,
uint8_t  value 
)
inline

在文件 utils.h51 行定义.

51 {
52 return (value >> 4) == static_cast<uint8_t>(label);
53}

◆ IsSemanticLabel()

bool apollo::perception::camera::IsSemanticLabel ( PointSemanticLabel  label,
uint8_t  value 
)
inline

在文件 utils.h37 行定义.

37 {
38 return (value & 15) == static_cast<uint8_t>(label);
39}

◆ jaccard_overlap_gpu()

__host__ __device__ float apollo::perception::camera::jaccard_overlap_gpu ( const float *  bbox1,
const float *  bbox2 
)

◆ LaneVisualization()

bool apollo::perception::camera::LaneVisualization ( onboard::CameraFrame frame,
const std::string &  file_name 
)

在文件 visualizer.cc119 行定义.

120 {
121 return true;
122}

◆ LoadAnchors()

bool apollo::perception::camera::LoadAnchors ( const std::string &  path,
std::vector< float > *  anchors 
)

在文件 util.cc31 行定义.

31 {
32 int num_anchors = 0;
33 std::ifstream ifs(path, std::ifstream::in);
34 ifs >> num_anchors;
35 if (!ifs.good()) {
36 AERROR << "Failed to get number of anchors!";
37 return false;
38 }
39 (*anchors).resize(num_anchors * 2);
40 for (int i = 0; i < num_anchors; ++i) {
41 ifs >> (*anchors)[i * 2] >> (*anchors)[i * 2 + 1];
42 if (!ifs.good()) {
43 AERROR << "Failed to load the " << i << "-th anchor!";
44 return false;
45 }
46 }
47 ifs.close();
48 return true;
49}

◆ LoadExpand()

bool apollo::perception::camera::LoadExpand ( const std::string &  path,
std::vector< float > *  expands 
)

在文件 util.cc72 行定义.

72 {
73 std::ifstream ifs(path, std::ifstream::in);
74 if (!ifs.good()) {
75 AERROR << "expand_list not found: " << path;
76 return false;
77 }
78 float expand;
79 AINFO << "Expand nums: ";
80 while (ifs >> expand) {
81 expands->push_back(expand);
82 AINFO << "\t\t" << expand;
83 }
84 ifs.close();
85 return true;
86}

◆ LoadKittiLabel()

bool apollo::perception::camera::LoadKittiLabel ( onboard::CameraFrame frame,
const std::string &  kitti_path,
const std::string &  dist_type 
)

Read KITTI labels and fill to frame->detected_objects

参数
frameonboard::CameraFrame
kitti_pathkitti path include labels
dist_type"H-from-h" or "H-on-h"
返回
true
false

在文件 ground_truth.cc43 行定义.

44 {
45 frame->detected_objects.clear();
46 FILE *fp = fopen(kitti_path.c_str(), "r");
47 if (fp == nullptr) {
48 AERROR << "Failed to load object file: " << kitti_path;
49 return false;
50 }
51
52 while (!feof(fp)) {
53 base::ObjectPtr obj = nullptr;
54 obj.reset(new base::Object);
55 float trash = 0.0f;
56 float score = 0.0f;
57 char type[255];
58 float x1 = 0.0f;
59 float y1 = 0.0f;
60 float x2 = 0.0f;
61 float y2 = 0.0f;
62 memset(type, 0, sizeof(type));
63
64 int ret = 0;
65 ret = fscanf(fp, "%254s %f %f %lf %f %f %f %f %f %f %f %lf %lf %lf %f %f",
66 type, &trash, &trash, &obj->camera_supplement.alpha, &x1, &y1,
67 &x2, &y2, &obj->size[2], &obj->size[1], &obj->size[0],
68 &obj->center[0], &obj->center[1], &obj->center[2], &obj->theta,
69 &score);
70 AINFO << "fscanf return: " << ret;
71 if (dist_type == "H-from-h") {
72 obj->size[0] = static_cast<float>(obj->center[2]);
73 } else if (dist_type == "H-on-h") {
74 obj->size[0] = static_cast<float>(obj->center[2]) * (y2 - y1);
75 } else {
76 AERROR << "Not supported dist type! " << dist_type;
77 return false;
78 }
79 obj->camera_supplement.box.xmin = std::max<float>(x1, 0);
80 obj->camera_supplement.box.ymin = std::max<float>(y1, 0);
81 obj->camera_supplement.box.xmax =
82 std::min<float>(
83 x2, static_cast<float>(frame->data_provider->src_width()));
84 obj->camera_supplement.box.ymax =
85 std::min<float>(
86 y2, static_cast<float>(frame->data_provider->src_height()));
87 obj->camera_supplement.area_id = 5;
88
89 if (object_subtype_map.find(type) == object_subtype_map.end()) {
90 obj->sub_type = base::ObjectSubType::UNKNOWN;
91 } else {
92 obj->sub_type = object_subtype_map.at(type);
93 }
94 obj->type = base::kSubType2TypeMap.at(obj->sub_type);
95 obj->type_probs.assign(
96 static_cast<int>(base::ObjectType::MAX_OBJECT_TYPE), 0);
97 obj->sub_type_probs.assign(
98 static_cast<int>(base::ObjectSubType::MAX_OBJECT_TYPE), 0);
99 obj->sub_type_probs[static_cast<int>(obj->sub_type)] = score;
100 obj->type_probs[static_cast<int>(obj->type)] = score;
101
102 frame->detected_objects.push_back(obj);
103 }
104
105 fclose(fp);
106 return true;
107}
const std::map< std::string, base::ObjectSubType > object_subtype_map

◆ LoadTypes()

bool apollo::perception::camera::LoadTypes ( const std::string &  path,
std::vector< base::ObjectSubType > *  types 
)

在文件 util.cc51 行定义.

52 {
53 std::ifstream ifs(path, std::ifstream::in);
54 if (!ifs.good()) {
55 AERROR << "Type_list not found: " << path;
56 return false;
57 }
58 std::string type;
59 AINFO << "Supported types: ";
60 while (ifs >> type) {
61 if (base::kName2SubTypeMap.find(type) == base::kName2SubTypeMap.end()) {
62 AERROR << "Invalid type: " << type;
63 return false;
64 }
65 (*types).push_back(base::kName2SubTypeMap.at(type));
66 AINFO << "\t\t" << type;
67 }
68 AINFO << "\t\t" << (*types).size() << " in total.";
69 ifs.close();
70 return true;
71}

◆ Normalize()

void apollo::perception::camera::Normalize ( const std::vector< float > &  mean,
const std::vector< float > &  std,
float  scale,
cv::Mat *  img 
)

Image normalize function

参数
meanThe mean value of the image.
stdThe standard deviation of the image.
scaleThe scale value of the image.
imThe image to be normalized.

在文件 preprocess.cc33 行定义.

34 {
35 ACHECK(std.size() == 3);
36 for (const auto std_value : std) {
37 ACHECK(std_value != 0.0);
38 }
39 if (scale) {
40 (*img).convertTo(*img, CV_32FC3, scale);
41 }
42 for (int h = 0; h < img->rows; ++h) {
43 for (int w = 0; w < img->cols; ++w) {
44 img->at<cv::Vec3f>(h, w)[0] =
45 (img->at<cv::Vec3f>(h, w)[0] - mean[0]) / std[0];
46 img->at<cv::Vec3f>(h, w)[1] =
47 (img->at<cv::Vec3f>(h, w)[1] - mean[1]) / std[1];
48 img->at<cv::Vec3f>(h, w)[2] =
49 (img->at<cv::Vec3f>(h, w)[2] - mean[2]) / std[2];
50 }
51 }
52}

◆ nppDupImageChannels()

bool apollo::perception::camera::nppDupImageChannels ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height 
)

在文件 image_data_operations_npp.h76 行定义.

78 {
79 NppStatus status;
80 NppiSize roi;
81 roi.height = src_height;
82 roi.width = src_width;
83 status = nppiDup_8u_C1C3R(src->gpu_data(), src->width_step(),
84 dst->mutable_gpu_data(), dst->width_step(), roi);
85 if (status != NPP_SUCCESS) {
86 return false;
87 }
88 return true;
89}

◆ nppImageRemap()

bool apollo::perception::camera::nppImageRemap ( const base::Image8U src_img,
base::Image8U dst_img,
const int  src_width,
const int  src_height,
const base::Blob< float > &  map_x,
const base::Blob< float > &  map_y 
)

在文件 image_data_operations_npp.h91 行定义.

94 {
95 NppiInterpolationMode remap_mode = NPPI_INTER_LINEAR;
96 NppiSize image_size;
97 image_size.width = src_width;
98 image_size.height = src_height;
99 NppiRect remap_roi = {0, 0, src_width, src_height};
100 NppStatus status = NPP_SUCCESS;
101 int d_map_step = static_cast<int>(map_x.shape(1) * sizeof(float));
102 switch (src_img.channels()) {
103 case 1:
104 status = nppiRemap_8u_C1R(src_img.gpu_data(), image_size,
105 src_img.width_step(), remap_roi,
106 map_x.gpu_data(), d_map_step, map_y.gpu_data(),
107 d_map_step, dst_img->mutable_gpu_data(),
108 dst_img->width_step(), image_size, remap_mode);
109 break;
110 case 3:
111 status = nppiRemap_8u_C3R(src_img.gpu_data(), image_size,
112 src_img.width_step(), remap_roi,
113 map_x.gpu_data(), d_map_step, map_y.gpu_data(),
114 d_map_step, dst_img->mutable_gpu_data(),
115 dst_img->width_step(), image_size, remap_mode);
116 break;
117 default:
118 AERROR << "Invalid number of channels: " << src_img.channels();
119 return false;
120 }
121 if (status != NPP_SUCCESS) {
122 AERROR << "NPP_CHECK_NPP - status = " << status;
123 return false;
124 }
125 return true;
126}
const Dtype * gpu_data() const
Definition blob.cc:154
const std::vector< int > & shape() const
Definition blob.h:130
const uint8_t * gpu_data() const
Definition image_8u.h:101

◆ nppImageToBlob()

bool apollo::perception::camera::nppImageToBlob ( const base::Image8U image,
base::Blob< uint8_t > *  blob 
)

在文件 image_data_operations_npp.h22 行定义.

22 {
23 NppStatus status;
24 NppiSize roi;
25 roi.height = image.rows();
26 roi.width = image.cols();
27 blob->Reshape({1, roi.height, roi.width, image.channels()});
28 if (image.channels() == 1) {
29 status = nppiCopy_8u_C1R(
30 image.gpu_data(), image.width_step(), blob->mutable_gpu_data(),
31 blob->count(2) * static_cast<int>(sizeof(uint8_t)), roi);
32 } else {
33 status = nppiCopy_8u_C3R(
34 image.gpu_data(), image.width_step(), blob->mutable_gpu_data(),
35 blob->count(2) * static_cast<int>(sizeof(uint8_t)), roi);
36 }
37 if (status != NPP_SUCCESS) {
38 return false;
39 }
40 return true;
41}
void Reshape(const int num, const int channels, const int height, const int width)
Deprecated; use Reshape(const std::vector<int>& shape).
Definition blob.cc:72

◆ nppImageToGray()

bool apollo::perception::camera::nppImageToGray ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height,
const float  coeffs[3] 
)

在文件 image_data_operations_npp.h43 行定义.

45 {
46 NppStatus status;
47 NppiSize roi;
48 roi.height = src_height;
49 roi.width = src_width;
50 status = nppiColorToGray_8u_C3C1R(src->gpu_data(), src->width_step(),
51 dst->mutable_gpu_data(), dst->width_step(),
52 roi, coeffs);
53 if (status != NPP_SUCCESS) {
54 return false;
55 }
56 return true;
57}

◆ nppSwapImageChannels()

bool apollo::perception::camera::nppSwapImageChannels ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height,
const int  order[3] 
)

在文件 image_data_operations_npp.h59 行定义.

62 {
63 NppStatus status;
64 NppiSize roi;
65 roi.height = src_height;
66 roi.width = src_width;
67 status = nppiSwapChannels_8u_C3R(src->gpu_data(), src->width_step(),
68 dst->mutable_gpu_data(), dst->width_step(),
69 roi, order);
70 if (status != NPP_SUCCESS) {
71 return false;
72 }
73 return true;
74}

◆ Occlude()

template<typename T >
bool apollo::perception::camera::Occlude ( const T *  bbox1,
const T &  h1,
const T *  bbox2,
const T &  h2 
)

在文件 twod_threed_util.h127 行定义.

127 {
128 T overlap_x = std::min(bbox1[2], bbox2[2]) - std::max(bbox1[0], bbox2[0]);
129 T overlap_y = std::min(bbox1[3], bbox2[3]) - std::max(bbox1[1], bbox2[1]);
130 if (overlap_y <= (T)0 || overlap_x <= (T)0) {
131 return false;
132 }
133 const T HEIGHT_BIG_MOT = static_cast<T>(3.0f);
134 const T OCC_RATIO = (T)0.1f;
135 T bh1 = bbox1[3] - bbox1[1];
136 T bh2 = bbox2[3] - bbox2[1];
137 T inter_area = overlap_x * overlap_y;
138 T area = bh2 * (bbox2[2] - bbox2[0]);
139 T occ_ratio = inter_area * algorithm::IRec(area);
140 T thres_occ_ratio = h2 < HEIGHT_BIG_MOT ? 2 * OCC_RATIO : OCC_RATIO;
141 bool occ = occ_ratio > thres_occ_ratio &&
142 h1 * algorithm::IRec(bh1) < h2 * algorithm::IRec(bh2);
143 return occ;
144}

◆ operator<<()

std::ostream & apollo::perception::camera::operator<< ( std::ostream &  os,
const CarPose pose 
)

在文件 pose.cc60 行定义.

60 {
61 os << pose.pose_;
62 return os;
63}

◆ OutOfValidRegion() [1/2]

template<typename T >
bool apollo::perception::camera::OutOfValidRegion ( const base::BBox2D< T >  box,
const T  width,
const T  height,
const T  border_size = 0 
)

在文件 util.h74 行定义.

75 {
76 if (box.xmin < border_size || box.ymin < border_size) {
77 return true;
78 }
79 if (box.xmax + border_size > width || box.ymax + border_size > height) {
80 return true;
81 }
82 return false;
83}

◆ OutOfValidRegion() [2/2]

template<typename T >
bool apollo::perception::camera::OutOfValidRegion ( const base::Rect< T >  rect,
const T  width,
const T  height,
const T  border_size = 0 
)

在文件 util.h85 行定义.

86 {
87 base::BBox2D<T> box(rect);
88 return OutOfValidRegion(box, width, height, border_size);
89}
bool OutOfValidRegion(const base::BBox2D< T > box, const T width, const T height, const T border_size=0)
Definition util.h:74

◆ PERCEPTION_REGISTER_CAMERA_PERCEPTION()

apollo::perception::camera::PERCEPTION_REGISTER_CAMERA_PERCEPTION ( LaneCameraPerception  )

◆ PERCEPTION_REGISTER_CIPV()

apollo::perception::camera::PERCEPTION_REGISTER_CIPV ( Cipv  )

◆ PERCEPTION_REGISTER_MATCHER()

apollo::perception::camera::PERCEPTION_REGISTER_MATCHER ( HMMatcher  )

◆ PERCEPTION_REGISTER_REGISTERER() [1/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseCalibrationService  )

◆ PERCEPTION_REGISTER_REGISTERER() [2/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseCalibrator  )

◆ PERCEPTION_REGISTER_REGISTERER() [3/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseCameraPerception  )

◆ PERCEPTION_REGISTER_REGISTERER() [4/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseCipv  )

◆ PERCEPTION_REGISTER_REGISTERER() [5/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseFeatureExtractor  )

◆ PERCEPTION_REGISTER_REGISTERER() [6/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseLaneDetector  )

◆ PERCEPTION_REGISTER_REGISTERER() [7/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseLanePostprocessor  )

◆ PERCEPTION_REGISTER_REGISTERER() [8/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseMatcher  )

◆ PERCEPTION_REGISTER_REGISTERER() [9/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseObstacleDetector  )

◆ PERCEPTION_REGISTER_REGISTERER() [10/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseObstacleTracker  )

◆ PERCEPTION_REGISTER_REGISTERER() [11/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BasePostprocessor  )

◆ PERCEPTION_REGISTER_REGISTERER() [12/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BasePredictor  )

◆ PERCEPTION_REGISTER_REGISTERER() [13/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseTracker  )

◆ PERCEPTION_REGISTER_REGISTERER() [14/14]

apollo::perception::camera::PERCEPTION_REGISTER_REGISTERER ( BaseTransformer  )

◆ PERCEPTION_REGISTER_TRACKER()

apollo::perception::camera::PERCEPTION_REGISTER_TRACKER ( CameraTracker  )

◆ PolyEval()

template<typename Dtype >
bool apollo::perception::camera::PolyEval ( const Dtype &  x,
int  order,
const Eigen::Matrix< Dtype, max_poly_order+1, 1 > &  coeff,
Dtype *  y 
)

在文件 common_functions.h96 行定义.

98 {
99 int poly_order = order;
100 if (order > max_poly_order) {
101 AERROR << "the order of polynomial function must be smaller than "
102 << max_poly_order;
103 return false;
104 }
105
106 *y = static_cast<Dtype>(0);
107 for (int j = 0; j <= poly_order; ++j) {
108 *y += static_cast<Dtype>(coeff(j) * std::pow(x, j));
109 }
110
111 return true;
112}

◆ PolyFit()

template<typename Dtype >
bool apollo::perception::camera::PolyFit ( const EigenVector< Eigen::Matrix< Dtype, 2, 1 > > &  pos_vec,
const int &  order,
Eigen::Matrix< Dtype, max_poly_order+1, 1 > *  coeff,
const bool &  is_x_axis = true 
)

在文件 common_functions.h51 行定义.

54 {
55 if (coeff == nullptr) {
56 AERROR << "The coefficient pointer is NULL.";
57 return false;
58 }
59
60 if (order > max_poly_order) {
61 AERROR << "The order of polynomial must be smaller than " << max_poly_order;
62 return false;
63 }
64
65 int n = static_cast<int>(pos_vec.size());
66 if (n <= order) {
67 AERROR << "The number of points should be larger than the order. #points = "
68 << pos_vec.size();
69 return false;
70 }
71
72 // create data matrix
73 Eigen::Matrix<Dtype, Eigen::Dynamic, Eigen::Dynamic> A(n, order + 1);
74 Eigen::Matrix<Dtype, Eigen::Dynamic, 1> y(n);
75 Eigen::Matrix<Dtype, Eigen::Dynamic, 1> result;
76 for (int i = 0; i < n; ++i) {
77 for (int j = 0; j <= order; ++j) {
78 A(i, j) = static_cast<Dtype>(
79 std::pow(is_x_axis ? pos_vec[i].x() : pos_vec[i].y(), j));
80 }
81 y(i) = is_x_axis ? pos_vec[i].y() : pos_vec[i].x();
82 }
83
84 // solve linear least squares
85 result = A.householderQr().solve(y);
86 assert(result.size() == order + 1);
87
88 for (int j = 0; j <= max_poly_order; ++j) {
89 (*coeff)(j) = (j <= order) ? result(j) : static_cast<Dtype>(0);
90 }
91
92 return true;
93}
const size_t A
Definition util.h:160

◆ ProjectBox()

void apollo::perception::camera::ProjectBox ( const base::BBox2DF box_origin,
const Eigen::Matrix3d &  transform,
base::BBox2DF box_projected 
)

在文件 omt_obstacle_tracker.cc356 行定义.

358 {
359 Eigen::Vector3d point;
360 // top left
361 point << box_origin.xmin, box_origin.ymin, 1;
362 point = transform * point;
363 box_projected->xmin = static_cast<float>(point[0] / point[2]);
364 box_projected->ymin = static_cast<float>(point[1] / point[2]);
365 // bottom right
366 point << box_origin.xmax, box_origin.ymax, 1;
367 point = transform * point;
368 box_projected->xmax = static_cast<float>(point[0] / point[2]);
369 box_projected->ymax = static_cast<float>(point[1] / point[2]);
370}

◆ QSwap_()

template<class T >
void apollo::perception::camera::QSwap_ ( T *  a,
T *  b 
)

在文件 common_functions.h283 行定义.

283 {
284 T temp = *a;
285 *a = *b;
286 *b = temp;
287}

◆ QuickSort() [1/2]

template<class T >
void apollo::perception::camera::QuickSort ( int *  index,
const T *  values,
int  nsize 
)

在文件 common_functions.h340 行定义.

340 {
341 for (int ii = 0; ii < nsize; ii++) {
342 index[ii] = ii;
343 }
344 QuickSort(index, values, 0, nsize);
345}

◆ QuickSort() [2/2]

template<class T >
void apollo::perception::camera::QuickSort ( int *  index,
const T *  values,
int  start,
int  end 
)

在文件 common_functions.h290 行定义.

290 {
291 if (start >= end - 1) {
292 return;
293 }
294
295 const T& pivot = values[index[(start + end - 1) / 2]];
296 // first, split into two parts: less than the pivot
297 // and greater-or-equal
298 int lo = start;
299 int hi = end;
300
301 for (;;) {
302 while (lo < hi && values[index[lo]] < pivot) {
303 lo++;
304 }
305 while (lo < hi && values[index[hi - 1]] >= pivot) {
306 hi--;
307 }
308 if (lo == hi || lo == hi - 1) {
309 break;
310 }
311 QSwap_(&(index[lo]), &(index[hi - 1]));
312 lo++;
313 hi--;
314 }
315
316 int split1 = lo;
317 // now split into two parts: equal to the pivot
318 // and strictly greater.
319 hi = end;
320 for (;;) {
321 while (lo < hi && values[index[lo]] == pivot) {
322 lo++;
323 }
324 while (lo < hi && values[index[hi - 1]] > pivot) {
325 hi--;
326 }
327 if (lo == hi || lo == hi - 1) {
328 break;
329 }
330 QSwap_(&(index[lo]), &(index[hi - 1]));
331 lo++;
332 hi--;
333 }
334 int split2 = lo;
335 QuickSort(index, values, start, split1);
336 QuickSort(index, values, split2, end);
337}
void QuickSort(int *index, const T *values, int start, int end)

◆ RansacFitting()

template<typename Dtype >
bool apollo::perception::camera::RansacFitting ( const EigenVector< Eigen::Matrix< Dtype, 2, 1 > > &  pos_vec,
EigenVector< Eigen::Matrix< Dtype, 2, 1 > > *  selected_points,
Eigen::Matrix< Dtype, 4, 1 > *  coeff,
const int  max_iters = 100,
const int  N = 5,
const Dtype  inlier_thres = static_cast<Dtype>(0.1) 
)

在文件 common_functions.h116 行定义.

120 {
121 if (coeff == nullptr) {
122 AERROR << "The coefficient pointer is NULL.";
123 return false;
124 }
125
126 selected_points->clear();
127
128 int n = static_cast<int>(pos_vec.size());
129 int q1 = static_cast<int>(n / 4);
130 int q2 = static_cast<int>(n / 2);
131 int q3 = static_cast<int>(n * 3 / 4);
132 if (n < N) {
133 AERROR << "The number of points should be larger than the order. #points = "
134 << pos_vec.size();
135 return false;
136 }
137
138 std::vector<int> index(3, 0);
139 int max_inliers = 0;
140 Dtype min_residual = std::numeric_limits<float>::max();
141 Dtype early_stop_ratio = 0.95f;
142 Dtype good_lane_ratio = 0.666f;
143 for (int j = 0; j < max_iters; ++j) {
144 index[0] = std::rand() % q2;
145 index[1] = q2 + std::rand() % q1;
146 index[2] = q3 + std::rand() % q1;
147
148 Eigen::Matrix<Dtype, 3, 3> matA;
149 matA << pos_vec[index[0]](0) * pos_vec[index[0]](0), pos_vec[index[0]](0),
150 1, pos_vec[index[1]](0) * pos_vec[index[1]](0), pos_vec[index[1]](0), 1,
151 pos_vec[index[2]](0) * pos_vec[index[2]](0), pos_vec[index[2]](0), 1;
152
153 Eigen::FullPivLU<Eigen::Matrix<Dtype, 3, 3>> mat(matA);
154 mat.setThreshold(1e-5f);
155 if (mat.rank() < 3) {
156 ADEBUG << "matA: " << matA;
157 ADEBUG << "Matrix is not full rank (3). The rank is: " << mat.rank();
158 continue;
159 }
160
161 // Since Eigen::solver was crashing, simple inverse of 3x3 matrix is used
162 // Note that Eigen::inverse of 3x3 and 4x4 is a closed form solution
163 Eigen::Matrix<Dtype, 3, 1> matB;
164 matB << pos_vec[index[0]](1), pos_vec[index[1]](1), pos_vec[index[2]](1);
165 Eigen::Vector3f c =
166 static_cast<Eigen::Matrix<Dtype, 3, 1>>(matA.inverse() * matB);
167 if (!(matA * c).isApprox(matB)) {
168 ADEBUG << "No solution.";
169 continue;
170 }
171
172 int num_inliers = 0;
173 Dtype residual = 0;
174 Dtype y = 0;
175 for (int i = 0; i < n; ++i) {
176 y = pos_vec[i](0) * pos_vec[i](0) * c(0) + pos_vec[i](0) * c(1) + c(2);
177 if (std::abs(y - pos_vec[i](1)) <= inlier_thres) ++num_inliers;
178 residual += std::abs(y - pos_vec[i](1));
179 }
180
181 if (num_inliers > max_inliers ||
182 (num_inliers == max_inliers && residual < min_residual)) {
183 (*coeff)(3) = 0;
184 (*coeff)(2) = c(0);
185 (*coeff)(1) = c(1);
186 (*coeff)(0) = c(2);
187 max_inliers = num_inliers;
188 min_residual = residual;
189 }
190
191 if (max_inliers > early_stop_ratio * n) break;
192 }
193
194 if (static_cast<Dtype>(max_inliers) / n < good_lane_ratio) return false;
195
196 // EigenVector<Eigen::Matrix<Dtype, 2, 1>> tmp = *pos_vec;
197 // pos_vec.clear();
198 for (int i = 0; i < n; ++i) {
199 Dtype y = pos_vec[i](0) * pos_vec[i](0) * (*coeff)(2) +
200 pos_vec[i](0) * (*coeff)(1) + (*coeff)(0);
201 if (std::abs(y - pos_vec[i](1)) <= inlier_thres) {
202 selected_points->push_back(pos_vec[i]);
203 }
204 }
205 return true;
206}

◆ recover_bbox()

void apollo::perception::camera::recover_bbox ( int  roi_w,
int  roi_h,
int  offset_y,
std::vector< base::ObjectPtr > *  objects 
)

recover detect bbox result to raw image

参数
roi_wroi width
roi_hroi height
offset_yoffset y
objectsdetection result

在文件 postprocess.cc267 行定义.

268 {
269 for (auto &obj : *objects) {
270 float xmin = obj->camera_supplement.box.xmin;
271 float ymin = obj->camera_supplement.box.ymin;
272 float xmax = obj->camera_supplement.box.xmax;
273 float ymax = obj->camera_supplement.box.ymax;
274 int x = static_cast<int>(xmin * static_cast<float>(roi_w));
275 int w = static_cast<int>((xmax - xmin) * static_cast<float>(roi_w));
276 int y = static_cast<int>(ymin * static_cast<float>(roi_h)) + offset_y;
277 int h = static_cast<int>((ymax - ymin) * static_cast<float>(roi_h));
278 base::RectF rect_det(static_cast<float>(x), static_cast<float>(y),
279 static_cast<float>(w), static_cast<float>(h));
280 base::RectF rect_img(0, 0, static_cast<float>(roi_w),
281 static_cast<float>(roi_h + offset_y));
282 base::RectF rect = rect_det & rect_img;
283 obj->camera_supplement.box = rect;
284
285 double eps = 1e-2;
286
287 // Truncation assignment based on bbox positions
288 if ((ymin < eps) || (ymax >= 1.0 - eps)) {
289 obj->camera_supplement.truncated_vertical = 0.5;
290 } else {
291 obj->camera_supplement.truncated_vertical = 0.0;
292 }
293 if ((xmin < eps) || (xmax >= 1.0 - eps)) {
294 obj->camera_supplement.truncated_horizontal = 0.5;
295 } else {
296 obj->camera_supplement.truncated_horizontal = 0.0;
297 }
298
299 obj->camera_supplement.front_box.xmin *= static_cast<float>(roi_w);
300 obj->camera_supplement.front_box.ymin *= static_cast<float>(roi_h);
301 obj->camera_supplement.front_box.xmax *= static_cast<float>(roi_w);
302 obj->camera_supplement.front_box.ymax *= static_cast<float>(roi_h);
303
304 obj->camera_supplement.back_box.xmin *= static_cast<float>(roi_w);
305 obj->camera_supplement.back_box.ymin *= static_cast<float>(roi_h);
306 obj->camera_supplement.back_box.xmax *= static_cast<float>(roi_w);
307 obj->camera_supplement.back_box.ymax *= static_cast<float>(roi_h);
308
309 obj->camera_supplement.front_box.ymin += static_cast<float>(offset_y);
310 obj->camera_supplement.front_box.ymax += static_cast<float>(offset_y);
311 obj->camera_supplement.back_box.ymin += static_cast<float>(offset_y);
312 obj->camera_supplement.back_box.ymax += static_cast<float>(offset_y);
313 }
314}

◆ RecoverBBox()

void apollo::perception::camera::RecoverBBox ( int  roi_w,
int  roi_h,
int  offset_y,
std::vector< base::ObjectPtr > *  objects 
)

在文件 postprocess.cc48 行定义.

49 {
50 for (auto &obj : *objects) {
51 float xmin = obj->camera_supplement.box.xmin;
52 float ymin = obj->camera_supplement.box.ymin;
53 float xmax = obj->camera_supplement.box.xmax;
54 float ymax = obj->camera_supplement.box.ymax;
55
56 float x = xmin * roi_w;
57 float w = (xmax - xmin) * roi_w;
58 float y = ymin * roi_h + offset_y;
59 float h = (ymax - ymin) * roi_h;
60 base::RectF rect_det(x, y, w, h);
61 base::RectF rect_img(0, 0, roi_w, roi_h + offset_y);
62 obj->camera_supplement.box = rect_det & rect_img;
63
64 constexpr double eps = 1e-2;
65 // Truncation assignment based on bbox positions
66 if ((ymin < eps) || (ymax >= (1.0 - eps))) {
67 obj->camera_supplement.truncated_vertical = 0.5;
68 } else {
69 obj->camera_supplement.truncated_vertical = 0.0;
70 }
71
72 if ((xmin < eps) || (xmax >= (1.0 - eps))) {
73 obj->camera_supplement.truncated_horizontal = 0.5;
74 } else {
75 obj->camera_supplement.truncated_horizontal = 0.0;
76 }
77 }
78}

◆ RecoveryImage()

bool apollo::perception::camera::RecoveryImage ( onboard::CameraFrame frame,
cv::Mat *  cv_img 
)

Recovery cv image from frame->data_provider

参数
frameonboard::CameraFrame
cv_imgcv image
返回
true
false

在文件 util.cc46 行定义.

46 {
47 DataProvider::ImageOptions image_options;
48 image_options.target_color = base::Color::BGR;
49 image_options.do_crop = false;
50 base::Image8U image(frame->data_provider->src_height(),
51 frame->data_provider->src_width(), base::Color::RGB);
52 frame->data_provider->GetImage(image_options, &image);
53
54 memcpy(cv_img->data, image.cpu_data(), image.total() * sizeof(uint8_t));
55 return true;
56}
A wrapper around Blob holders serving as the basic computational unit for images.
Definition image_8u.h:44

◆ RefineBox() [1/2]

template<typename T >
void apollo::perception::camera::RefineBox ( const base::BBox2D< T > &  box_in,
const T  width,
const T  height,
base::BBox2D< T > *  box_out 
)

在文件 util.h128 行定义.

129 {
130 if (!box_out) {
131 return;
132 }
133 base::Rect<T> rect;
134 RefineBox(base::Rect<T>(box_in), width, height, &rect);
135 *box_out = base::BBox2D<T>(rect);
136}

◆ RefineBox() [2/2]

template<typename T >
void apollo::perception::camera::RefineBox ( const base::Rect< T > &  box_in,
const T  width,
const T  height,
base::Rect< T > *  box_out 
)

在文件 util.h92 行定义.

93 {
94 if (!box_out) {
95 return;
96 }
97 *box_out = box_in;
98 if (box_out->x < 0) {
99 box_out->width += box_out->x;
100 box_out->x = 0;
101 }
102 if (box_out->y < 0) {
103 box_out->height += box_out->y;
104 box_out->y = 0;
105 }
106 if (box_out->x >= width) {
107 box_out->x = 0;
108 box_out->width = 0;
109 }
110 if (box_out->y >= height) {
111 box_out->y = 0;
112 box_out->height = 0;
113 }
114 box_out->width = (box_out->x + box_out->width <= width) ? box_out->width
115 : width - box_out->x;
116 box_out->height = (box_out->y + box_out->height <= height)
117 ? box_out->height
118 : height - box_out->y;
119 if (box_out->width < 0) {
120 box_out->width = 0;
121 }
122 if (box_out->height < 0) {
123 box_out->height = 0;
124 }
125}

◆ REGISTER_CALIBRATION_SERVICE()

apollo::perception::camera::REGISTER_CALIBRATION_SERVICE ( OnlineCalibrationService  )

◆ REGISTER_CALIBRATOR()

apollo::perception::camera::REGISTER_CALIBRATOR ( LaneLineCalibrator  )

◆ REGISTER_FEATURE_EXTRACTOR() [1/3]

apollo::perception::camera::REGISTER_FEATURE_EXTRACTOR ( ExternalFeatureExtractor  )

◆ REGISTER_FEATURE_EXTRACTOR() [2/3]

apollo::perception::camera::REGISTER_FEATURE_EXTRACTOR ( ProjectFeature  )

◆ REGISTER_FEATURE_EXTRACTOR() [3/3]

apollo::perception::camera::REGISTER_FEATURE_EXTRACTOR ( TrackingFeatureExtractor  )

◆ REGISTER_LANE_DETECTOR() [1/2]

apollo::perception::camera::REGISTER_LANE_DETECTOR ( DarkSCNNLaneDetector  )

◆ REGISTER_LANE_DETECTOR() [2/2]

apollo::perception::camera::REGISTER_LANE_DETECTOR ( DenselineLaneDetector  )

◆ REGISTER_LANE_POSTPROCESSOR() [1/2]

apollo::perception::camera::REGISTER_LANE_POSTPROCESSOR ( DarkSCNNLanePostprocessor  )

◆ REGISTER_LANE_POSTPROCESSOR() [2/2]

apollo::perception::camera::REGISTER_LANE_POSTPROCESSOR ( DenselineLanePostprocessor  )

◆ REGISTER_OBSTACLE_DETECTOR() [1/6]

apollo::perception::camera::REGISTER_OBSTACLE_DETECTOR ( BEVFORMERObstacleDetector  )

◆ REGISTER_OBSTACLE_DETECTOR() [2/6]

apollo::perception::camera::REGISTER_OBSTACLE_DETECTOR ( BEVObstacleDetector  )

◆ REGISTER_OBSTACLE_DETECTOR() [3/6]

apollo::perception::camera::REGISTER_OBSTACLE_DETECTOR ( CaddnObstacleDetector  )

◆ REGISTER_OBSTACLE_DETECTOR() [4/6]

apollo::perception::camera::REGISTER_OBSTACLE_DETECTOR ( SmokeObstacleDetector  )

◆ REGISTER_OBSTACLE_DETECTOR() [5/6]

apollo::perception::camera::REGISTER_OBSTACLE_DETECTOR ( YoloObstacleDetector  )

◆ REGISTER_OBSTACLE_DETECTOR() [6/6]

apollo::perception::camera::REGISTER_OBSTACLE_DETECTOR ( Yolox3DObstacleDetector  )

◆ REGISTER_OBSTACLE_POSTPROCESSOR()

apollo::perception::camera::REGISTER_OBSTACLE_POSTPROCESSOR ( LocationRefinerPostprocessor  )

◆ REGISTER_OBSTACLE_TRACKER()

apollo::perception::camera::REGISTER_OBSTACLE_TRACKER ( OMTObstacleTracker  )

◆ REGISTER_OBSTACLE_TRANSFORMER() [1/2]

apollo::perception::camera::REGISTER_OBSTACLE_TRANSFORMER ( MultiCueTransformer  )

◆ REGISTER_OBSTACLE_TRANSFORMER() [2/2]

apollo::perception::camera::REGISTER_OBSTACLE_TRANSFORMER ( SingleStageTransformer  )

◆ remap_pkd3_kernel()

__global__ void apollo::perception::camera::remap_pkd3_kernel ( const uchar3 *  src,
size_t  src_width_step,
uchar3 *  dst,
size_t  dst_width_step,
const float *  mapx,
const float *  mapy,
int  width,
int  height 
)

在文件 image_data_operations_rpp.h228 行定义.

231 {
232 const size_t i = hipBlockDim_x * hipBlockIdx_x + hipThreadIdx_x;
233 const size_t j = hipBlockDim_y * hipBlockIdx_y + hipThreadIdx_y;
234
235 image2D<uchar3> src_img{src, src_width_step};
236 image2D<uchar3> dst_img{dst, dst_width_step};
237
238 if (i < width && j < height) {
239 float x_coor = mapx[j * width + i];
240 float y_coor = mapy[j * width + i];
241
242 int X = trunc(x_coor);
243 int Y = trunc(y_coor);
244 float x_frac = x_coor - X;
245 float y_frac = y_coor - Y;
246
247 if (0 <= X && X < width && 0 <= Y && Y < height) {
248 // uchar3 p[2][2];
249 int X1 = (X < width - 1) ? X + 1 : X;
250 int Y1 = (Y < height - 1) ? Y + 1 : Y;
251
252 uchar3 pixel00 = src_img(X, Y);
253 uchar3 pixel01 = src_img(X1, Y);
254 uchar3 pixel10 = src_img(X, Y1);
255 uchar3 pixel11 = src_img(X1, Y1);
256 // bilinear interpolation
257 uchar3 interpolated;
258 interpolated.x =
259 (pixel00.x * (1 - x_frac) + pixel01.x * x_frac) * (1 - y_frac) +
260 (pixel10.x * (1 - x_frac) + pixel11.x * x_frac) * y_frac;
261 interpolated.y =
262 (pixel00.y * (1 - x_frac) + pixel01.y * x_frac) * (1 - y_frac) +
263 (pixel10.y * (1 - x_frac) + pixel11.y * x_frac) * y_frac;
264 interpolated.z =
265 (pixel00.z * (1 - x_frac) + pixel01.z * x_frac) * (1 - y_frac) +
266 (pixel10.z * (1 - x_frac) + pixel11.z * x_frac) * y_frac;
267
268 dst_img(i, j) = interpolated;
269 }
270 }
271}

◆ remap_pln1_kernel()

__global__ void apollo::perception::camera::remap_pln1_kernel ( const unsigned char *  src,
size_t  src_width_step,
unsigned char *  dst,
size_t  dst_width_step,
const float *  mapx,
const float *  mapy,
int  width,
int  height 
)

在文件 image_data_operations_rpp.h193 行定义.

196 {
197 const size_t i = hipBlockDim_x * hipBlockIdx_x + hipThreadIdx_x;
198 const size_t j = hipBlockDim_y * hipBlockIdx_y + hipThreadIdx_y;
199 image2D<unsigned char> src_img{src, src_width_step};
200 image2D<unsigned char> dst_img{dst, dst_width_step};
201 if (i < width && j < height) {
202 float x_coor = mapx[j * width + i];
203 float y_coor = mapy[j * width + i];
204
205 int X = trunc(x_coor);
206 int Y = trunc(y_coor);
207 float x_frac = x_coor - X;
208 float y_frac = y_coor - Y;
209
210 if (0 <= X && X < width && 0 <= Y && Y < height) {
211 // uchar p[2][2];
212 int X1 = (X < width - 1) ? X + 1 : X;
213 int Y1 = (Y < height - 1) ? Y + 1 : Y;
214
215 unsigned char pixel00 = src_img(X, Y);
216 unsigned char pixel01 = src_img(X1, Y);
217 unsigned char pixel10 = src_img(X, Y1);
218 unsigned char pixel11 = src_img(X1, Y1);
219 // bilinear interpolation
220 unsigned char interpolated =
221 (pixel00 * (1 - x_frac) + pixel01 * x_frac) * (1 - y_frac) +
222 (pixel10 * (1 - x_frac) + pixel11 * x_frac) * y_frac;
223 dst_img(i, j) = interpolated;
224 }
225 }
226}

◆ Resize() [1/3]

void apollo::perception::camera::Resize ( const cv::Mat &  input_img,
cv::Mat *  out_img,
cv::Size  size,
double  fx = 0,
double  fy = 0,
int  interpolation = cv::INTER_LINEAR 
)

◆ Resize() [2/3]

void apollo::perception::camera::Resize ( const cv::Mat &  input_img,
cv::Mat *  out_img,
int  width,
int  height,
double  fx,
double  fy,
int  interpolation 
)

在文件 camera_preprocess_general_util.cc40 行定义.

41 {
42 ACHECK(nullptr != out_img);
43 cv::resize(input_img, *out_img, cv::Size(width, height), fx, fy,
44 interpolation);
45}

◆ Resize() [3/3]

void apollo::perception::camera::Resize ( cv::Mat *  img,
cv::Mat *  img_n,
int  width,
int  height 
)

Image resize function

参数
imgThe image to be resized.
widthThe width of the image.
heightThe height of the image.

在文件 preprocess.cc24 行定义.

24 {
25 cv::resize(*img, *img_n, cv::Size(width, height));
26}

◆ ResizeCPU()

bool apollo::perception::camera::ResizeCPU ( const base::Blob< uint8_t > &  src_blob,
std::shared_ptr< base::Blob< float > >  dst_blob,
int  stepwidth,
int  start_axis 
)

在文件 util.cc87 行定义.

89 {
90 int width = dst_blob->shape(2);
91 int height = dst_blob->shape(1);
92 int channel = dst_blob->shape(3);
93 int origin_channel = src_blob.shape(3);
94 int origin_height = src_blob.shape(1);
95 int origin_width = src_blob.shape(2);
96 if (origin_channel != dst_blob->shape(3)) {
97 AERROR << "channel should be the same after resize.";
98 return false;
99 }
100 float fx = static_cast<float>(origin_width) / static_cast<float>(width);
101 float fy = static_cast<float>(origin_height) / static_cast<float>(height);
102 auto src = src_blob.cpu_data();
103 auto dst = dst_blob->mutable_cpu_data();
104 for (int dst_y = 0; dst_y < height; dst_y++) {
105 for (int dst_x = 0; dst_x < width; dst_x++) {
106 float src_x = (static_cast<float>(dst_x) + 0.5f) * fx - 0.5f;
107 float src_y = (static_cast<float>(dst_y) + 0.5f) * fy - 0.5f;
108 const int x1 = static_cast<int>(src_x + 0.5);
109 const int y1 = static_cast<int>(src_y + 0.5);
110 const int x1_read = std::max(x1, 0);
111 const int y1_read = std::max(y1, 0);
112 const int x2 = x1 + 1;
113 const int y2 = y1 + 1;
114 const int x2_read = std::min(x2, width - 1);
115 const int y2_read = std::min(y2, height - 1);
116 int src_reg = 0;
117 for (int c = 0; c < channel; c++) {
118 float out = 0.0f;
119
120 int idx11 = (y1_read * stepwidth + x1_read) * channel;
121 src_reg = src[idx11 + c];
122 out = out + (static_cast<float>(x2) - src_x) *
123 (static_cast<float>(y2) - src_y) *
124 static_cast<float>(src_reg);
125 int idx12 = (y1_read * stepwidth + x2_read) * channel;
126 src_reg = src[idx12 + c];
127 out = out + static_cast<float>(src_reg) *
128 (src_x - static_cast<float>(x1)) *
129 (static_cast<float>(y2) - src_y);
130
131 int idx21 = (y2_read * stepwidth + x1_read) * channel;
132 src_reg = src[idx21 + c];
133 out = out + static_cast<float>(src_reg) *
134 (static_cast<float>(x2) - src_x) *
135 (src_y - static_cast<float>(y1));
136
137 int idx22 = (y2_read * stepwidth + x2_read) * channel;
138 src_reg = src[idx22 + c];
139 out = out + static_cast<float>(src_reg) *
140 (src_x - static_cast<float>(x1)) *
141 (src_y - static_cast<float>(y1));
142 if (out < 0) {
143 out = 0;
144 }
145 if (out > 255) {
146 out = 255;
147 }
148 int dst_idx = (dst_y * width + dst_x) * channel + c;
149 // printf("%f %d %d %d %d\n",out,x1,y1,x2,y2);
150 dst[dst_idx] = out;
151 }
152 }
153 }
154 return true;
155}

◆ resizeKeepAspectRatioYolox()

cv::Mat apollo::perception::camera::resizeKeepAspectRatioYolox ( const cv::Mat &  input,
const cv::Size &  dstSize,
const cv::Scalar &  bgcolor 
)

在文件 yolox3d_obstacle_detector.cc120 行定义.

122 {
123 cv::Mat output;
124
125 double h1 = dstSize.width * (input.rows / static_cast<double>(input.cols));
126 double w2 = dstSize.height * (input.cols / static_cast<double>(input.rows));
127 if (h1 <= dstSize.height) {
128 cv::resize(input, output, cv::Size(dstSize.width, h1));
129 } else {
130 cv::resize(input, output, cv::Size(w2, dstSize.height));
131 }
132
133 int top = (dstSize.height - output.rows) / 2;
134 int down = (dstSize.height - output.rows + 1) / 2;
135 int left = (dstSize.width - output.cols) / 2;
136 int right = (dstSize.width - output.cols + 1) / 2;
137
138 cv::copyMakeBorder(output, output, top, down, left, right,
139 cv::BORDER_CONSTANT, bgcolor);
140
141 return output;
142}

◆ rppDupImageChannels()

bool apollo::perception::camera::rppDupImageChannels ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height 
)

在文件 image_data_operations_rpp.h176 行定义.

178 {
179 dim3 threadsPerBlock(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y);
180 dim3 blocks((src_width + threadsPerBlock.x - 1) / threadsPerBlock.x,
181 (src_height + threadsPerBlock.y - 1) / threadsPerBlock.y);
182
183 hipLaunchKernelGGL(duplicate_kernel, blocks, threadsPerBlock, 0, 0,
184 src->gpu_data(), src->width_step(),
185 reinterpret_cast<uchar3 *>(dst->mutable_gpu_data()),
186 dst->width_step(), src_width, src_height);
187
188 if (hipSuccess != hipGetLastError())
189 return false;
190 return true;
191}

◆ rppImageRemap()

bool apollo::perception::camera::rppImageRemap ( const base::Image8U src_img,
base::Image8U dst_img,
const int  src_width,
const int  src_height,
const base::Blob< float > &  map_x,
const base::Blob< float > &  map_y 
)

在文件 image_data_operations_rpp.h273 行定义.

276 {
277 dim3 threadsPerBlock(THREADS_PER_BLOCK_X, THREADS_PER_BLOCK_Y);
278 dim3 blocks((src_width + threadsPerBlock.x - 1) / threadsPerBlock.x,
279 (src_height + threadsPerBlock.y - 1) / threadsPerBlock.y);
280
281 switch (src_img.channels()) {
282 case 1:
283 hipLaunchKernelGGL(remap_pln1_kernel, blocks, threadsPerBlock, 0, 0,
284 src_img.gpu_data(), src_img.width_step(),
285 dst_img->mutable_gpu_data(), dst_img->width_step(),
286 map_x.gpu_data(), map_y.gpu_data(), src_width,
287 src_height);
288 break;
289 case 3:
290 hipLaunchKernelGGL(
291 remap_pkd3_kernel, blocks, threadsPerBlock, 0, 0,
292 reinterpret_cast<const uchar3 *>(src_img.gpu_data()),
293 src_img.width_step(),
294 reinterpret_cast<uchar3 *>(dst_img->mutable_gpu_data()),
295 dst_img->width_step(), map_x.gpu_data(), map_y.gpu_data(), src_width,
296 src_height);
297 break;
298 default:
299 AERROR << "Invalid number of channels: " << src_img.channels()
300 << "; only 1 and 3 are supported.";
301 return false;
302 }
303 if (hipSuccess != hipGetLastError())
304 return false;
305 return true;
306}

◆ rppImageToBlob()

bool apollo::perception::camera::rppImageToBlob ( const base::Image8U image,
base::Blob< uint8_t > *  blob 
)

在文件 image_data_operations_rpp.h74 行定义.

74 {
75 RpptDesc srcDesc, dstDesc;
76 RpptDescPtr srcDescPtr = &srcDesc, dstDescPtr = &dstDesc;
77
78 blob->Reshape({1, image.rows(), image.cols(), image.channels()});
79
80 if (!rppInitDescriptor(srcDescPtr, image.cols(), image.rows(),
81 image.channels(), image.width_step()))
82 return false;
83 if (!rppInitDescriptor(dstDescPtr, image.cols(), image.rows(), image.channels(),
84 blob->count(2) * static_cast<int>(sizeof(uint8_t))))
85 return false;
86
87 rppHandle_t handle;
88 rppCreateWithBatchSize(&handle, 1);
89 RppStatus status =
90 rppt_copy_gpu((const_cast<base::Image8U &>(image)).mutable_gpu_data(),
91 srcDescPtr, blob->mutable_gpu_data(), dstDescPtr, handle);
92 if (status != RPP_SUCCESS)
93 return false;
94 return true;
95}

◆ rppImageToGray()

bool apollo::perception::camera::rppImageToGray ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height,
const float  coeffs[3] 
)

在文件 image_data_operations_rpp.h97 行定义.

99 {
100 RppStatus status = RPP_SUCCESS;
101 RpptDesc srcDesc, dstDesc;
102 RpptDescPtr srcDescPtr = &srcDesc, dstDescPtr = &dstDesc;
103
104 if (!rppInitDescriptor(srcDescPtr, src_width, src_height, 3,
105 src->width_step()))
106 return false;
107 if (!rppInitDescriptor(dstDescPtr, src_width, src_height, 1,
108 dst->width_step()))
109 return false;
110
111 rppHandle_t handle;
112 rppCreateWithBatchSize(&handle, 1);
113 assert((coeffs[1] == 0.587f) &&
114 ((coeffs[0] == 0.114f && coeffs[2] == 0.299f) ||
115 (coeffs[0] == 0.299f && coeffs[2] == 0.114f)) &&
116 "coefficients in rppt_color_to_greyscale_gpu are hardcoded");
117 // BGR: float coeffs[] = {0.114f, 0.587f, 0.299f};
118 if (coeffs[0] == 0.114f && coeffs[1] == 0.587f && coeffs[2] == 0.299f) {
119 status = rppt_color_to_greyscale_gpu(src->mutable_gpu_data(), srcDescPtr,
120 dst->mutable_gpu_data(), dstDescPtr,
121 RpptSubpixelLayout::BGRtype, handle);
122 }
123 // RGB: float coeffs[] = {0.299f, 0.587f, 0.114f};
124 if (coeffs[0] == 0.299f && coeffs[1] == 0.587f && coeffs[2] == 0.114f) {
125 status = rppt_color_to_greyscale_gpu(src->mutable_gpu_data(), srcDescPtr,
126 dst->mutable_gpu_data(), dstDescPtr,
127 RpptSubpixelLayout::RGBtype, handle);
128 }
129 if (status != RPP_SUCCESS)
130 return false;
131 return true;
132}
bool rppInitDescriptor(RpptDescPtr &descPtr, int width, int height, int channels, int width_step)

◆ rppInitDescriptor()

bool apollo::perception::camera::rppInitDescriptor ( RpptDescPtr &  descPtr,
int  width,
int  height,
int  channels,
int  width_step 
)

在文件 image_data_operations_rpp.h41 行定义.

42 {
43 descPtr->dataType = RpptDataType::U8;
44 descPtr->numDims = 4;
45 descPtr->offsetInBytes = 0;
46 descPtr->n = 1;
47 descPtr->h = height;
48 descPtr->w = width;
49 descPtr->c = channels;
50 switch (channels) {
51 case 1:
52 descPtr->layout = RpptLayout::NCHW;
53 descPtr->strides.wStride = 1;
54 descPtr->strides.hStride = width_step;
55 descPtr->strides.cStride = descPtr->strides.hStride * descPtr->h;
56 descPtr->strides.nStride =
57 descPtr->strides.hStride * descPtr->h * descPtr->c;
58 break;
59 case 3:
60 descPtr->layout = RpptLayout::NHWC;
61 descPtr->strides.cStride = 1;
62 descPtr->strides.wStride = descPtr->c;
63 descPtr->strides.hStride = width_step;
64 descPtr->strides.nStride = descPtr->strides.hStride * descPtr->h;
65 break;
66 default:
67 AERROR << "Invalid number of channels: " << channels
68 << "; only 1 and 3 are supported.";
69 return false;
70 }
71 return true;
72}

◆ rppSwapImageChannels()

bool apollo::perception::camera::rppSwapImageChannels ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height,
const int  order[3] 
)

在文件 image_data_operations_rpp.h134 行定义.

137 {
138 RpptDesc srcDesc, dstDesc;
139 RpptDescPtr srcDescPtr = &srcDesc, dstDescPtr = &dstDesc;
140
141 if (!rppInitDescriptor(srcDescPtr, src_width, src_height, 3,
142 src->width_step()))
143 return false;
144 if (!rppInitDescriptor(dstDescPtr, src_width, src_height, 3,
145 dst->width_step()))
146 return false;
147
148 rppHandle_t handle;
149 rppCreateWithBatchSize(&handle, 1);
150 assert(order[0] == 2 && order[1] == 1 && order[2] == 0 &&
151 "The order in rppt_swap_channels is hardcoded");
152 RppStatus status =
153 rppt_swap_channels_gpu(src->mutable_gpu_data(), srcDescPtr,
154 dst->mutable_gpu_data(), dstDescPtr, handle);
155 if (status != RPP_SUCCESS)
156 return false;
157 return true;
158}

◆ SaveCameraDetectionResult()

bool apollo::perception::camera::SaveCameraDetectionResult ( onboard::CameraFrame frame,
const std::string &  file_name 
)

Save detection result to file_name

参数
frameonboard::CameraFrame
file_nameresult file
返回
true
false

在文件 util.cc84 行定义.

85 {
86 FILE* fp = fopen(file_name.c_str(), "w");
87 if (fp == nullptr) {
88 AERROR << "Failed to open result file: " << file_name;
89 return false;
90 }
91
92 for (auto obj : frame->detected_objects) {
93 auto& supp = obj->camera_supplement;
94 fprintf(fp,
95 "%s 0 0 %6.3f %8.2f %8.2f %8.2f %8.2f %6.3f %6.3f %6.3f "
96 "%6.3f %6.3f %6.3f %6.3f %6.3f "
97 "%4d %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
98 base::kSubType2NameMap.at(obj->sub_type).c_str(), supp.alpha,
99 supp.box.xmin, supp.box.ymin, supp.box.xmax, supp.box.ymax,
100 obj->size[2], obj->size[1], obj->size[0], obj->center[0],
101 obj->center[1] + obj->size[2] * .5, obj->center[2],
102 supp.alpha + atan2(obj->center[0], obj->center[2]),
103 obj->type_probs[static_cast<int>(obj->type)], supp.area_id,
104 supp.visible_ratios[0], supp.visible_ratios[1],
105 supp.visible_ratios[2], supp.visible_ratios[3],
106 supp.cut_off_ratios[0], supp.cut_off_ratios[1],
107 supp.cut_off_ratios[2], supp.cut_off_ratios[3]);
108 }
109
110 fclose(fp);
111 return true;
112}

◆ SaveLaneDetectionResult()

bool apollo::perception::camera::SaveLaneDetectionResult ( onboard::CameraFrame frame,
const std::string &  file_name 
)

在文件 util.cc119 行定义.

120 {
121 return true;
122}

◆ SaveTfDetectionResult()

bool apollo::perception::camera::SaveTfDetectionResult ( onboard::CameraFrame frame,
const std::string &  file_name 
)

在文件 util.cc114 行定义.

115 {
116 return true;
117}

◆ SetSceneFlowLabel()

void apollo::perception::camera::SetSceneFlowLabel ( PointSemanticLabel  label,
uint8_t *  value 
)
inline

在文件 utils.h42 行定义.

42 {
43 *value &= 15; // 15: 00001111
44 *value = (static_cast<uint8_t>(label) << 4) | (*value);
45}

◆ SetSemanticLabel()

void apollo::perception::camera::SetSemanticLabel ( PointSemanticLabel  label,
uint8_t *  value 
)
inline

在文件 utils.h28 行定义.

28 {
29 *value &= 240; // 240: 11110000
30 *value |= static_cast<uint8_t>(label);
31}

◆ sigmoid()

template<typename Dtype >
Dtype apollo::perception::camera::sigmoid ( Dtype  x)
inline

在文件 math_functions.h25 行定义.

25 {
26 return static_cast<Dtype>(1.0) /
27 static_cast<Dtype>(1.0 + exp(static_cast<double>(-x)));
28}

◆ sigmoid_gpu()

__host__ __device__ float apollo::perception::camera::sigmoid_gpu ( float  x)

◆ sort_score_pair_descend()

template<typename T >
bool apollo::perception::camera::sort_score_pair_descend ( const std::pair< float, T > &  pair1,
const std::pair< float, T > &  pair2 
)

在文件 postprocess.h135 行定义.

136 {
137 return pair1.first > pair2.first;
138}

◆ spatialLUT()

◆ sqr()

template<typename Dtype >
Dtype apollo::perception::camera::sqr ( Dtype  x)

在文件 math_functions.h35 行定义.

35 {
36 return x * x;
37}

◆ swapImageChannels()

bool apollo::perception::camera::swapImageChannels ( const base::Image8UPtr src,
const base::Image8UPtr dst,
const int  src_width,
const int  src_height,
const int  order[3] 
)

在文件 image_data_operations.cc49 行定义.

51 {
52 return nppSwapImageChannels(src, dst, src_width, src_height, order);
53}
bool nppSwapImageChannels(const base::Image8UPtr &src, const base::Image8UPtr &dst, const int src_width, const int src_height, const int order[3])

◆ TestDetection()

bool apollo::perception::camera::TestDetection ( )

在文件 offline_camera_detection.cc64 行定义.

64 {
65 // Init frame
66 onboard::CameraFrame camera_frame;
67 camera_frame.data_provider.reset(new DataProvider());
68 camera_frame.feature_blob.reset(new base::Blob<float>());
69
70 // Init data
71 ACHECK(InitDataProvider(&camera_frame));
72
73 ObstacleDetectorInitOptions init_options;
74 // Init conf file
75 init_options.config_path = FLAGS_config_path;
76 init_options.config_file = FLAGS_config_file;
77 init_options.gpu_id = FLAGS_gpu_id;
78
79 // Init camera params
80 std::string camera_name = FLAGS_camera_name;
82 algorithm::SensorManager::Instance()->GetUndistortCameraModel(
83 camera_name);
84 ACHECK(model) << "Can't find " << camera_name
85 << " in data/conf/sensor_meta.pb.txt";
86 auto pinhole = static_cast<base::PinholeCameraModel*>(model.get());
87 init_options.intrinsic = pinhole->get_intrinsic_params();
88 camera_frame.camera_k_matrix = pinhole->get_intrinsic_params();
89 init_options.image_height = model->get_height();
90 init_options.image_width = model->get_width();
91 // Init detection pipeline
92 std::shared_ptr<BaseObstacleDetector> detector;
93 detector.reset(
94 BaseObstacleDetectorRegisterer::GetInstanceByName(FLAGS_detector_name));
95 detector->Init(init_options);
96
97 // Load image list
98 std::string images_path = FLAGS_root_dir + "/images/";
99 std::vector<std::string> img_file_names;
100 if (!algorithm::GetFileList(images_path, ".jpg", &img_file_names)) {
101 AERROR << "images_path: " << images_path << " get file list error.";
102 return false;
103 }
104
105 std::sort(img_file_names.begin(), img_file_names.end(),
106 [](const std::string& lhs, const std::string& rhs) {
107 if (lhs.length() != rhs.length()) {
108 return lhs.length() < rhs.length();
109 }
110 return lhs <= rhs;
111 });
112
113 // Main process
114 for (const auto& img_file : img_file_names) {
115 AINFO << "img_file: " << img_file;
116
117 std::string image_name = cyber::common::GetFileName(img_file, true);
118
119 if (FLAGS_kitti_dir != "") {
120 std::string kitti_path = FLAGS_kitti_dir + "/" + image_name + ".txt";
121
122 if (!LoadKittiLabel(&camera_frame, kitti_path, FLAGS_dist_type)) {
123 AERROR << "Loading kitti result failed: " << kitti_path;
124 continue;
125 }
126 } else {
127 ACHECK(FillImage(&camera_frame, img_file));
128 ACHECK(detector->Detect(&camera_frame));
129 }
130
131 // Results visualization
132 if (!cyber::common::EnsureDirectory(FLAGS_dest_dir)) {
133 AERROR << "Failed to create: " << FLAGS_dest_dir;
134 return false;
135 }
136
137 std::string result_path = FLAGS_dest_dir + "/" + image_name + ".txt";
138 ACHECK(SaveCameraDetectionResult(&camera_frame, result_path));
139
140 result_path = FLAGS_dest_dir + "/" + image_name + ".jpg";
141 ACHECK(CameraVisualization(&camera_frame, result_path));
142 }
143
144 return true;
145}
A wrapper around SyncedMemory holders serving as the basic computational unit for images,...
Definition blob.h:88
std::shared_ptr< BaseCameraModel > BaseCameraModelPtr
Definition camera.h:75
bool FillImage(onboard::CameraFrame *frame, const std::string &file_name)
Read image from file_name and fill in frame->data_provider
Definition util.cc:28
bool CameraVisualization(onboard::CameraFrame *frame, const std::string &file_name)
Save visualization results to file_name(.jpg)
Definition visualizer.cc:40
bool InitDataProvider(onboard::CameraFrame *camera_frame)
bool SaveCameraDetectionResult(onboard::CameraFrame *frame, const std::string &file_name)
Save detection result to file_name
Definition util.cc:84

◆ TfVisualization()

bool apollo::perception::camera::TfVisualization ( onboard::CameraFrame frame,
const std::string &  file_name 
)

在文件 visualizer.cc114 行定义.

115 {
116 return true;
117}

◆ UpdateOffsetZ()

template<typename T >
void apollo::perception::camera::UpdateOffsetZ ( x_start,
z_start,
x_end,
z_end,
const std::pair< T, T > &  range,
T *  z_offset 
)

在文件 twod_threed_util.h252 行定义.

253 {
254 ACHECK(range.first < range.second);
255 if (x_start > x_end) {
256 std::swap(x_start, x_end);
257 std::swap(z_start, z_end);
258 }
259
260 T x_check_l = std::max(x_start, range.first);
261 T x_check_r = std::min(x_end, range.second);
262 T overlap_x = x_check_r - x_check_l;
263 if (overlap_x < 1e-6) {
264 return;
265 }
266
267 T dz_divide_dx = (z_end - z_start) * algorithm::IRec(x_end - x_start);
268 T z_check_l = z_start + (x_check_l - x_start) * dz_divide_dx;
269 T z_check_r = z_start + (x_check_r - x_start) * dz_divide_dx;
270 T z_nearest = std::min(z_check_l, z_check_r);
271 if (z_nearest < *z_offset) {
272 *z_offset = z_nearest;
273 }
274}

◆ WriteCalibrationOutput()

int apollo::perception::camera::WriteCalibrationOutput ( bool  enabled,
const std::string &  out_path,
const CameraFrame frame 
)

在文件 debug_info.cc106 行定义.

107 {
108 if (!enabled) {
109 return -1;
110 }
111 float pitch_angle = 0.f;
112 float camera_ground_height = 0.f;
114 &camera_ground_height, &pitch_angle)) {
115 AERROR << "Failed to query camera to ground height and pitch.";
116 return -1;
117 }
118
119 FILE *file_save = fopen(out_path.data(), "wt");
120 if (file_save == nullptr) {
121 AERROR << "Failed to open output path: " << out_path.data();
122 return -1;
123 }
124 fprintf(file_save, "camera_ground_height:\t%f\n", camera_ground_height);
125 fprintf(file_save, "pitch_angle:\t%f\n", pitch_angle);
126 fclose(file_save);
127 return 0;
128}
virtual bool QueryCameraToGroundHeightAndPitchAngle(float *height, float *pitch) const
BaseCalibrationService * calibration_service

◆ WriteLanelines()

int apollo::perception::camera::WriteLanelines ( const bool  enabled,
const std::string &  save_path,
const std::vector< base::LaneLine > &  lane_objects 
)

在文件 debug_info.cc28 行定义.

29 {
30 if (!enabled) {
31 return -1;
32 }
33 FILE *file_save = fopen(save_path.data(), "wt");
34 if (file_save == nullptr) {
35 AERROR << "Failed to open lane save path: " << save_path;
36 return -1;
37 }
38 int lane_line_size = static_cast<int>(lane_objects.size());
39 AINFO << "Lane line num: " << lane_line_size;
40 fprintf(file_save, "[\n");
41 for (int j = 0; j < lane_line_size; ++j) {
42 const base::LaneLineCubicCurve &curve_camera =
43 lane_objects[j].curve_camera_coord;
44 const base::LaneLineCubicCurve &curve_img =
45 lane_objects[j].curve_image_coord;
46 const std::vector<base::Point3DF> &camera_point_set =
47 lane_objects[j].curve_camera_point_set;
48 const std::vector<base::Point2DF> &image_point_set =
49 lane_objects[j].curve_image_point_set;
50 fprintf(file_save, "{\n");
51 fprintf(file_save, "\"type\":%d,\n", lane_objects[j].type);
52 fprintf(file_save, "\"pos_type\":%d,\n", lane_objects[j].pos_type);
53 // Camera curve
54 fprintf(file_save, "\"camera_curve\":\n");
55 fprintf(file_save, "{\"a\":%.10f,\"b\":%.10f,\"c\":%.10f,\"d\":%.10f,",
56 curve_camera.a, curve_camera.b, curve_camera.c, curve_camera.d);
57 fprintf(file_save, "\"x0\":%.10f,\"x1\":%.10f},\n", curve_camera.x_start,
58 curve_camera.x_end);
59 // Camera image point set
60 fprintf(file_save, "\"camera_point_set\":\n");
61 fprintf(file_save, "[");
62 for (size_t k = 0; k < camera_point_set.size(); k++) {
63 if (k < camera_point_set.size() - 1) {
64 fprintf(file_save, "{\"x\":%.4f,\"y\":%.4f,\"z\":%.4f},",
65 camera_point_set[k].x, camera_point_set[k].y,
66 camera_point_set[k].z);
67 } else {
68 fprintf(file_save, "{\"x\":%.4f,\"y\":%.4f,\"z\":%.4f}",
69 camera_point_set[k].x, camera_point_set[k].y,
70 camera_point_set[k].z);
71 }
72 }
73 fprintf(file_save, "],");
74 fprintf(file_save, "\n");
75 // Image curve
76 fprintf(file_save, "\"image_curve\":\n");
77 fprintf(file_save, "{\"a\":%.10f,\"b\":%.10f,\"c\":%.10f,\"d\":%.10f,",
78 curve_img.a, curve_img.b, curve_img.c, curve_img.d);
79 fprintf(file_save, "\"x0\":%.10f,\"x1\":%.10f},\n", curve_img.x_start,
80 curve_img.x_end);
81 // Curve image point set
82 fprintf(file_save, "\"image_point_set\":\n");
83 fprintf(file_save, "[");
84 for (size_t k = 0; k < image_point_set.size(); ++k) {
85 if (k < image_point_set.size() - 1) {
86 fprintf(file_save, "{\"x\":%.4f,\"y\":%.4f},", image_point_set[k].x,
87 image_point_set[k].y);
88 } else {
89 fprintf(file_save, "{\"x\":%.4f,\"y\":%.4f}", image_point_set[k].x,
90 image_point_set[k].y);
91 }
92 }
93 fprintf(file_save, "]");
94 fprintf(file_save, "\n");
95 if (j < lane_line_size - 1) {
96 fprintf(file_save, "},\n");
97 } else {
98 fprintf(file_save, "}\n");
99 }
100 }
101 fprintf(file_save, "]\n");
102 fclose(file_save);
103 return 0;
104}

◆ YoloxBboxIOU()

float apollo::perception::camera::YoloxBboxIOU ( const std::vector< float > &  box1,
const std::vector< float > &  box2 
)

Computes IoU between bboxes.

参数
box1object label
box2object label
返回
Returns the IoU of two bboxes

在文件 postprocess.cc359 行定义.

360 {
361 const int center_x_index = 0;
362 const int center_y_index = 1;
363 const int width_index = 2;
364 const int height_index = 3;
365
366 int b1_x1 = static_cast<int>(box1[center_x_index]) -
367 std::floor(box1[width_index] / 2.0);
368 int b1_y1 = static_cast<int>(box1[center_y_index]) -
369 std::floor(box1[height_index] / 2.0);
370 int b1_x2 = static_cast<int>(box1[center_x_index]) +
371 std::floor(box1[width_index] / 2.0);
372 int b1_y2 = static_cast<int>(box1[center_y_index]) +
373 std::floor(box1[height_index] / 2.0);
374
375 int b2_x1 = static_cast<int>(box2[center_x_index]) -
376 std::floor(box2[width_index] / 2.0);
377 int b2_y1 = static_cast<int>(box2[center_y_index]) -
378 std::floor(box2[height_index] / 2.0);
379 int b2_x2 = static_cast<int>(box2[center_x_index]) +
380 std::floor(box2[width_index] / 2.0);
381 int b2_y2 = static_cast<int>(box2[center_y_index]) +
382 std::floor(box2[height_index] / 2.0);
383
384 // get the corrdinates of the intersection rectangle
385 int inter_rect_x1 = std::max(b1_x1, b2_x1);
386 int inter_rect_y1 = std::max(b1_y1, b2_y1);
387 int inter_rect_x2 = std::min(b1_x2, b2_x2);
388 int inter_rect_y2 = std::min(b1_y2, b2_y2);
389
390 // Intersection area
391 float inter_area = static_cast<float>(
392 Yoloxclamp(inter_rect_x2 - inter_rect_x1 + 1, 0, INT_MAX) *
393 Yoloxclamp(inter_rect_y2 - inter_rect_y1 + 1, 0, INT_MAX));
394 // Union Area
395 float b1_area = (b1_x2 - b1_x1 + 1) * (b1_y2 - b1_y1 + 1);
396 float b2_area = (b2_x2 - b2_x1 + 1) * (b2_y2 - b2_y1 + 1);
397
398 float iou = inter_area / (b1_area + b2_area - inter_area + 1e-3);
399 return iou;
400}
constexpr T Yoloxclamp(const T &val, const T &low, const T &high)
Clamp target value between low and high tools for iou

◆ Yoloxclamp()

template<typename T >
constexpr T apollo::perception::camera::Yoloxclamp ( const T &  val,
const T &  low,
const T &  high 
)
constexpr

Clamp target value between low and high tools for iou

参数
valtarget value
lowmin value
highmax value
返回
Returns clamped value

在文件 postprocess.h114 行定义.

114 {
115 return val < low ? low : (high < val ? high : val);
116}

◆ YoloxFillBase()

void apollo::perception::camera::YoloxFillBase ( const std::vector< float > &  detect,
const int  width,
const int  height,
const int  image_width,
const int  image_height,
base::ObjectPtr  obj 
)

Get 2dbbox for objects

参数
detectpointer to the detect blob
width640 resized image width
height640 resized image height
image_width1920 image width
image_height1080 image height
objpointer to the object

在文件 postprocess.cc303 行定义.

305 {
306 // yolo image size is (416, 416), raw image is (1080, 1920)
307 obj->camera_supplement.box.xmin = detect[0];
308 obj->camera_supplement.box.ymin = detect[1];
309 obj->camera_supplement.box.xmax = detect[0] + detect[2];
310 obj->camera_supplement.box.ymax = detect[1] + detect[3];
311}

◆ YoloxFillBbox3d()

void apollo::perception::camera::YoloxFillBbox3d ( const yolox3d::ModelParam model_param,
const std::vector< float > &  detect,
base::ObjectPtr  obj 
)

Add 3d bbox values for objects

参数
model_paramThe parameters of model
detectoutput of network
objpointer to the object

在文件 postprocess.cc313 行定义.

314 {
315 auto obj_l = 0.0;
316 auto obj_w = 0.0;
317 auto obj_h = 0.0;
318
319 if (model_param.with_box3d()) {
320 if (base ::ObjectType ::VEHICLE ==
321 base::kSubType2TypeMap.at(obj->sub_type)) {
322 obj_l = model_param.car_template().l();
323 obj_w = model_param.car_template().w();
324 obj_h = model_param.car_template().h();
325 if ("TRUCK" == base::kSubType2NameMap.at(obj->sub_type)) {
326 obj_l = model_param.car_template().l() * 1.5;
327 obj_w = model_param.car_template().w() * 1.5;
328 obj_h = model_param.car_template().h() * 1.5;
329 } else if ("BUS" == base::kSubType2NameMap.at(obj->sub_type)) {
330 obj_l = model_param.car_template().l() * 3;
331 obj_w = model_param.car_template().w() * 1.5;
332 obj_h = model_param.car_template().h() * 2.0;
333 }
334 } else if (base ::ObjectType ::PEDESTRIAN ==
335 base::kSubType2TypeMap.at(obj->sub_type)) {
336 obj_l = model_param.ped_template().l();
337 obj_w = model_param.ped_template().w();
338 obj_h = model_param.ped_template().h();
339 } else if (base ::ObjectType ::BICYCLE ==
340 base::kSubType2TypeMap.at(obj->sub_type)) {
341 obj_l = model_param.cyclist_template().l();
342 obj_w = model_param.cyclist_template().w();
343 obj_h = model_param.cyclist_template().h();
344 } else if (base ::ObjectType ::UNKNOWN_UNMOVABLE ==
345 base::kSubType2TypeMap.at(obj->sub_type)) {
346 obj_l = model_param.trafficcone_template().l();
347 obj_w = model_param.trafficcone_template().w();
348 obj_h = model_param.trafficcone_template().h();
349 }
350
351 // length, width, height
352 obj->size[0] = obj_l;
353 obj->size[1] = obj_w;
354 obj->size[2] = obj_h;
355 obj->camera_supplement.alpha = detect[8];
356 }
357}

◆ YoloxGetAllObjects()

void apollo::perception::camera::YoloxGetAllObjects ( const float *  data,
const yolox3d::ModelParam model_param,
const float  scale,
std::vector< std::vector< float > > *  objects_out 
)

Get all objects accoring to confidence

参数
datathe output blob data
model_paramThe parameters of model
objectspointer to the object

在文件 postprocess.cc238 行定义.

241 {
242 objects_out->clear();
243
244 std::vector<Object> objects;
245 std::vector<Object> proposals;
246 std::vector<int> strides = {8, 16, 32};
247 std::vector<GridAndStride> grid_strides;
248 generate_grids_and_stride(strides, grid_strides);
249 generate_yolox3d_proposals(grid_strides, data,
250 model_param.confidence_threshold(), proposals);
251 AINFO << "Yolox proposals size is " << proposals.size();
252
253 qsort_descent_inplace(proposals);
254 AINFO << "Yolox proposals after sort size is " << proposals.size();
255
256 std::vector<int> picked;
257 nms_sorted_bboxes(proposals, picked, model_param.nms_param().threshold());
258 AINFO << "Yolox objects after nms is " << picked.size();
259
260 int count = picked.size();
261 objects.resize(count);
262 for (int i = 0; i < count; i++) {
263 objects[i] = proposals[picked[i]];
264
265 // adjust offset to original unpadded
266 float x0 = (objects[i].rect.x) / scale;
267 float y0 = (objects[i].rect.y) / scale;
268 float x1 = (objects[i].rect.x + objects[i].rect.width) / scale;
269 float y1 = (objects[i].rect.y + objects[i].rect.height) / scale;
270
271 // clip
272 x0 = std::max(std::min(x0, static_cast<float>(1920 - 1)), 0.f);
273 y0 = std::max(std::min(y0, static_cast<float>(1920 - 1)), 0.f);
274 x1 = std::max(std::min(x1, static_cast<float>(1920 - 1)), 0.f);
275 y1 = std::max(std::min(y1, static_cast<float>(1920 - 1)), 0.f);
276
277 objects[i].rect.x = x0;
278 objects[i].rect.y = y0;
279 objects[i].rect.width = x1 - x0;
280 objects[i].rect.height = y1 - y0;
281
282 std::vector<float> object_temp;
283 object_temp.push_back(x0); // left x
284 object_temp.push_back(y0); // left y
285 object_temp.push_back(x1 - x0); // w
286 object_temp.push_back(y1 - y0); // h
287
288 object_temp.push_back(objects[i].prob); // score
289 object_temp.push_back(objects[i].label); // class label
290
291 objects_out->push_back(object_temp);
292 }
293}

◆ YoloxGetObjectsCpu()

void apollo::perception::camera::YoloxGetObjectsCpu ( const std::shared_ptr< base::Blob< float > > &  objects_blob,
const yolox3d::ModelParam model_param,
const yolox3d::NMSParam nms_param,
const int  width,
const int  height,
const int  image_width,
const int  image_height,
std::vector< base::ObjectPtr > *  objects 
)

Return Yolox Objects

参数
objects_blobthe object blob output from network
model_paramThe parameters of model
nms_paramThe parameters of NMS
width640 resized image width
height640 resized image height
image_widthimage width
image_heightthe image width and height
objectspointer to the object

在文件 postprocess.cc431 行定义.

436 {
437 ACHECK(objects_blob != nullptr);
438 ACHECK(objects != nullptr);
439
440 const float *detect_data = objects_blob->cpu_data();
441 ACHECK(detect_data != nullptr);
442
443 float scale = std::min(model_param.resize().width() / (image_width * 1.0),
444 model_param.resize().height() / (image_height * 1.0));
445
446 std::vector<std::vector<float>> detect_objects;
447 YoloxGetAllObjects(detect_data, model_param, scale, &detect_objects);
448
449 // center_x, center_y, width, height, class_score, class_label
450 objects->clear();
451 for (const std::vector<float> &detect : detect_objects) {
452 const int label = detect[kLabelIndex];
453 // ignore unknown
454 if (7 <= label) {
455 continue;
456 }
457
458 base::ObjectPtr obj = nullptr;
459 obj.reset(new base::Object);
460
461 obj->sub_type = kYoloSubTypeYolox[label];
462 obj->type = base::kSubType2TypeMap.at(obj->sub_type);
463 obj->confidence = detect[kScoreIndex];
464
465 obj->type_probs.assign(static_cast<int>(base::ObjectType::MAX_OBJECT_TYPE),
466 0);
467 obj->sub_type_probs.assign(
468 static_cast<int>(base::ObjectSubType::MAX_OBJECT_TYPE), 0);
469 obj->type_probs[static_cast<int>(obj->type)] = detect[kLabelIndex];
470 obj->sub_type_probs[static_cast<int>(obj->sub_type)] = detect[kLabelIndex];
471
472 YoloxFillBase(detect, width, height, image_width, image_height, obj);
473
474 YoloxFillBbox3d(model_param, detect, obj);
475
476 // TODO(lordon): add ignore truncated bool param
477 YoloxTruncated(obj, image_width, image_height);
478
479 objects->push_back(obj);
480 }
481}
void YoloxGetAllObjects(const float *data, const yolox3d::ModelParam &model_param, const float scale, std::vector< std::vector< float > > *objects_out)
Get all objects accoring to confidence

◆ YoloxTruncated()

void apollo::perception::camera::YoloxTruncated ( base::ObjectPtr  obj,
const int  image_width,
const int  image_height 
)

object is truncated or not

参数
objpointer to the object
image_width1920 image width
image_height1080 image height
返回
true
false

在文件 postprocess.cc402 行定义.

403 {
404 const float boundary_len = 20.0; // TODO(lordon): 20 piexl move it to conf
405 float min_x = static_cast<float>(boundary_len);
406 float min_y = static_cast<float>(boundary_len);
407 float max_x = static_cast<float>(image_width - boundary_len);
408 float max_y = static_cast<float>(image_height - boundary_len);
409 double eps = 1e-2;
410
411 if (obj->camera_supplement.box.xmin <= min_x ||
412 obj->camera_supplement.box.xmax >= max_x ||
413 obj->camera_supplement.box.ymin <= min_y ||
414 obj->camera_supplement.box.ymax >= max_y) {
415 // Truncation assignment based on bbox positions
416 if ((obj->camera_supplement.box.ymin < eps) ||
417 (obj->camera_supplement.box.ymax >= 1.0 - eps)) {
418 obj->camera_supplement.truncated_vertical = 0.5;
419 } else {
420 obj->camera_supplement.truncated_vertical = 0.0;
421 }
422 if ((obj->camera_supplement.box.xmin < eps) ||
423 (obj->camera_supplement.box.xmax >= 1.0 - eps)) {
424 obj->camera_supplement.truncated_horizontal = 0.5;
425 } else {
426 obj->camera_supplement.truncated_horizontal = 0.0;
427 }
428 }
429}

变量说明

◆ anchorSizeFactor

constexpr int apollo::perception::camera::anchorSizeFactor = 2
constexpr

在文件 postprocess.h125 行定义.

◆ colorlistobj

std::vector<cv::Scalar> apollo::perception::camera::colorlistobj
初始值:

在文件 visualizer.cc34 行定义.

34 {magenta_color, // last digit 0
35 purple_color, // last digit 1
36 teal_color, // last digit 2
37 violet_color, // last digit 3
38 pink_color, // last digit 4
39 beige_color, // last digit 5
40 ivory_color, // last digit 6
41 olive_color, // last digit 7
42 maroon_color, // last digit 8
43 lime_color}; // last digit 9

◆ colormapline

std::map<base::LaneLinePositionType, cv::Scalar> apollo::perception::camera::colormapline
初始值:
= {
{base::LaneLinePositionType::UNKNOWN, black_color},
{base::LaneLinePositionType::FOURTH_LEFT, sky_blue_color},
{base::LaneLinePositionType::THIRD_LEFT, dodger_blue_color},
{base::LaneLinePositionType::ADJACENT_LEFT, blue_color},
{base::LaneLinePositionType::EGO_LEFT, dark_blue_color},
{base::LaneLinePositionType::EGO_CENTER, light_green_color},
{base::LaneLinePositionType::EGO_RIGHT, red_color},
{base::LaneLinePositionType::ADJACENT_RIGHT, coral_color},
{base::LaneLinePositionType::THIRD_RIGHT, salmon_color},
{base::LaneLinePositionType::FOURTH_RIGHT, orange_color},
{base::LaneLinePositionType::OTHER, white_color},
{base::LaneLinePositionType::CURB_LEFT, cyan_color},
{base::LaneLinePositionType::CURB_RIGHT, yellow_color}}
cv::Scalar coral_color
Definition colormap.h:58
cv::Scalar salmon_color
Definition colormap.h:59
cv::Scalar red_color
Definition colormap.h:57
cv::Scalar yellow_color
Definition colormap.h:61
cv::Scalar black_color
Definition colormap.h:28
cv::Scalar orange_color
Definition colormap.h:60
cv::Scalar white_color
Definition colormap.h:29
cv::Scalar sky_blue_color
Definition colormap.h:41
cv::Scalar dodger_blue_color
Definition colormap.h:43
cv::Scalar cyan_color
Definition colormap.h:40
cv::Scalar light_green_color
Definition colormap.h:52

在文件 visualizer.cc45 行定义.

45 {
46 {base::LaneLinePositionType::UNKNOWN, black_color},
47 {base::LaneLinePositionType::FOURTH_LEFT, sky_blue_color},
48 {base::LaneLinePositionType::THIRD_LEFT, dodger_blue_color},
49 {base::LaneLinePositionType::ADJACENT_LEFT, blue_color},
50 {base::LaneLinePositionType::EGO_LEFT, dark_blue_color},
51 {base::LaneLinePositionType::EGO_CENTER, light_green_color},
52 {base::LaneLinePositionType::EGO_RIGHT, red_color},
53 {base::LaneLinePositionType::ADJACENT_RIGHT, coral_color},
54 {base::LaneLinePositionType::THIRD_RIGHT, salmon_color},
55 {base::LaneLinePositionType::FOURTH_RIGHT, orange_color},
56 {base::LaneLinePositionType::OTHER, white_color},
57 {base::LaneLinePositionType::CURB_LEFT, cyan_color},
58 {base::LaneLinePositionType::CURB_RIGHT, yellow_color}};
cv::Scalar dark_blue_color
Definition colormap.h:46

◆ [struct]

struct { ... } apollo::perception::camera::customLess

◆ EIGEN_ALIGN16

struct apollo::perception::camera::CameraFrame apollo::perception::camera::EIGEN_ALIGN16

◆ kApolloName2SubTypeMap

const std::map<std::string, base::ObjectSubType> apollo::perception::camera::kApolloName2SubTypeMap
初始值:
= {
{"smallMot", base::ObjectSubType::CAR},
{"bigMot", base::ObjectSubType::CAR},
{"nonMot", base::ObjectSubType::CYCLIST},
{"pedestrian", base::ObjectSubType::PEDESTRIAN},
{"TrainedOthers", base::ObjectSubType::TRAFFICCONE},
{"MAX_OBJECT_TYPE", base::ObjectSubType::MAX_OBJECT_TYPE},
}

在文件 bevformer_obstacle_detector.cc73 行定义.

73 {
74 {"smallMot", base::ObjectSubType::CAR},
75 {"bigMot", base::ObjectSubType::CAR},
76 {"nonMot", base::ObjectSubType::CYCLIST},
77 {"pedestrian", base::ObjectSubType::PEDESTRIAN},
78 {"TrainedOthers", base::ObjectSubType::TRAFFICCONE},
79 {"MAX_OBJECT_TYPE", base::ObjectSubType::MAX_OBJECT_TYPE},
80};

◆ kClassOfObstacles

constexpr int apollo::perception::camera::kClassOfObstacles = 8
constexpr

在文件 postprocess.cc30 行定义.

◆ kDropsHistorySize

const std::size_t apollo::perception::camera::kDropsHistorySize = 20

在文件 cipv_camera.h44 行定义.

◆ kIndex2ApolloName

const std::map<int, std::string> apollo::perception::camera::kIndex2ApolloName
初始值:
= {{0, "smallMot"},
{1, "bigMot"},
{2, "nonMot"},
{3, "pedestrian"},
{4, "TrainedOthers"}}

在文件 bevformer_obstacle_detector.cc82 行定义.

82 {{0, "smallMot"},
83 {1, "bigMot"},
84 {2, "nonMot"},
85 {3, "pedestrian"},
86 {4, "TrainedOthers"}};

◆ kIndex2NuScenesName

const std::map<int, std::string> apollo::perception::camera::kIndex2NuScenesName
初始值:
= {
{0, "car"}, {1, "truck"}, {2, "construction_vehicle"},
{3, "bus"}, {4, "trailer"}, {5, "barrier"},
{6, "motorcycle"}, {7, "bicycle"}, {8, "pedestrian"},
{9, "traffic_cone"},
}

在文件 bevformer_obstacle_detector.cc66 行定义.

66 {
67 {0, "car"}, {1, "truck"}, {2, "construction_vehicle"},
68 {3, "bus"}, {4, "trailer"}, {5, "barrier"},
69 {6, "motorcycle"}, {7, "bicycle"}, {8, "pedestrian"},
70 {9, "traffic_cone"},
71};

◆ kKITTIName2SubTypeMap

const std::map<std::string, base::ObjectSubType> apollo::perception::camera::kKITTIName2SubTypeMap
初始值:
= {
{"Car", base::ObjectSubType::CAR},
{"Pedestrian", base::ObjectSubType::PEDESTRIAN},
{"Cyclist", base::ObjectSubType::CYCLIST},
{"MAX_OBJECT_TYPE", base::ObjectSubType::MAX_OBJECT_TYPE},
}

在文件 caddn_obstacle_detector.cc33 行定义.

33 {
34 {"Car", base::ObjectSubType::CAR},
35 {"Pedestrian", base::ObjectSubType::PEDESTRIAN},
36 {"Cyclist", base::ObjectSubType::CYCLIST},
37 {"MAX_OBJECT_TYPE", base::ObjectSubType::MAX_OBJECT_TYPE},
38};

◆ kLabelIndex

constexpr int apollo::perception::camera::kLabelIndex = 5
constexpr

在文件 postprocess.cc33 行定义.

◆ kMaxAllowedSkipObject

const std::size_t apollo::perception::camera::kMaxAllowedSkipObject = 10

在文件 cipv_camera.h46 行定义.

◆ kMaxDistObjectToLaneInMeter

constexpr float apollo::perception::camera::kMaxDistObjectToLaneInMeter = 70.0f
constexpr

在文件 cipv_camera.h41 行定义.

◆ kMaxDistObjectToLaneInPixel

constexpr float apollo::perception::camera::kMaxDistObjectToLaneInPixel = 10.0f
constexpr

在文件 cipv_camera.h43 行定义.

◆ kMaxDistObjectToVirtualLaneInMeter

constexpr float apollo::perception::camera::kMaxDistObjectToVirtualLaneInMeter = 10.0f
constexpr

在文件 cipv_camera.h42 行定义.

◆ kMaxObjectNum

const std::size_t apollo::perception::camera::kMaxObjectNum = 100

在文件 cipv_camera.h45 行定义.

◆ kMinVelocity

constexpr float apollo::perception::camera::kMinVelocity = 10.0f
constexpr

在文件 cipv_camera.h40 行定义.

◆ kNuScenesName2SubTypeMap

const std::map< std::string, base::ObjectSubType > apollo::perception::camera::kNuScenesName2SubTypeMap
初始值:
= {
{"car", base::ObjectSubType::CAR},
{"truck", base::ObjectSubType::TRUCK},
{"construction_vehicle", base::ObjectSubType::CAR},
{"bus", base::ObjectSubType::BUS},
{"trailer", base::ObjectSubType::CAR},
{"barrier", base::ObjectSubType::UNKNOWN_UNMOVABLE},
{"motorcycle", base::ObjectSubType::MOTORCYCLIST},
{"bicycle", base::ObjectSubType::CYCLIST},
{"pedestrian", base::ObjectSubType::PEDESTRIAN},
{"traffic_cone", base::ObjectSubType::TRAFFICCONE},
{"MAX_OBJECT_TYPE", base::ObjectSubType::MAX_OBJECT_TYPE},
}

在文件 bev_obstacle_detector.cc31 行定义.

31 {
32 {"car", base::ObjectSubType::CAR},
33 {"truck", base::ObjectSubType::TRUCK},
34 {"construction_vehicle", base::ObjectSubType::CAR},
35 {"bus", base::ObjectSubType::BUS},
36 {"trailer", base::ObjectSubType::CAR},
37 {"barrier", base::ObjectSubType::UNKNOWN_UNMOVABLE},
38 {"motorcycle", base::ObjectSubType::MOTORCYCLIST},
39 {"bicycle", base::ObjectSubType::CYCLIST},
40 {"pedestrian", base::ObjectSubType::PEDESTRIAN},
41 {"traffic_cone", base::ObjectSubType::TRAFFICCONE},
42 {"MAX_OBJECT_TYPE", base::ObjectSubType::MAX_OBJECT_TYPE},
43};

◆ kScoreIndex

constexpr int apollo::perception::camera::kScoreIndex = 4
constexpr

在文件 postprocess.cc32 行定义.

◆ kTimeDiffDefault

const float apollo::perception::camera::kTimeDiffDefault = 0.067f

在文件 lane_based_calibrator.h31 行定义.

◆ kTypeCanBeRef

std::vector<base::ObjectSubType> apollo::perception::camera::kTypeCanBeRef
初始值:
= {base::ObjectSubType::CAR,
base::ObjectSubType::VAN}

在文件 object_template_manager.cc36 行定义.

36 {base::ObjectSubType::CAR,
37 base::ObjectSubType::VAN};

◆ kTypeRefinedByRef

std::vector<base::ObjectSubType> apollo::perception::camera::kTypeRefinedByRef
初始值:
= {
base::ObjectSubType::BUS, base::ObjectSubType::TRUCK,
base::ObjectSubType::PEDESTRIAN, base::ObjectSubType::TRAFFICCONE,
base::ObjectSubType::CYCLIST, base::ObjectSubType::MOTORCYCLIST,
base::ObjectSubType::TRICYCLIST}

在文件 object_template_manager.cc46 行定义.

46 {
47 base::ObjectSubType::BUS, base::ObjectSubType::TRUCK,
48 base::ObjectSubType::PEDESTRIAN, base::ObjectSubType::TRAFFICCONE,
49 base::ObjectSubType::CYCLIST, base::ObjectSubType::MOTORCYCLIST,
50 base::ObjectSubType::TRICYCLIST};

◆ kTypeRefinedByTemplate

std::vector<base::ObjectSubType> apollo::perception::camera::kTypeRefinedByTemplate
初始值:
= {
base::ObjectSubType::CAR, base::ObjectSubType::VAN,
base::ObjectSubType::BUS, base::ObjectSubType::TRUCK,
base::ObjectSubType::PEDESTRIAN, base::ObjectSubType::TRAFFICCONE,
base::ObjectSubType::CYCLIST, base::ObjectSubType::MOTORCYCLIST,
}

在文件 object_template_manager.cc39 行定义.

39 {
40 base::ObjectSubType::CAR, base::ObjectSubType::VAN,
41 base::ObjectSubType::BUS, base::ObjectSubType::TRUCK,
42 base::ObjectSubType::PEDESTRIAN, base::ObjectSubType::TRAFFICCONE,
43 base::ObjectSubType::CYCLIST, base::ObjectSubType::MOTORCYCLIST,
44};

◆ kVelocityDefault

const float apollo::perception::camera::kVelocityDefault = 8.333f

在文件 lane_based_calibrator.h30 行定义.

◆ kYawRateDefault

const float apollo::perception::camera::kYawRateDefault = 0.0f

在文件 lane_based_calibrator.h29 行定义.

◆ kYoloSubTypeYolox

const base::ObjectSubType apollo::perception::camera::kYoloSubTypeYolox[]
初始值:
= {
base::ObjectSubType::CAR, base::ObjectSubType::TRUCK,
base::ObjectSubType::VAN, base::ObjectSubType::BUS,
base::ObjectSubType::PEDESTRIAN, base::ObjectSubType::CYCLIST,
base::ObjectSubType::TRAFFICCONE, base::ObjectSubType::UNKNOWN,
}

在文件 postprocess.cc35 行定义.

35 {
36 base::ObjectSubType::CAR, base::ObjectSubType::TRUCK,
37 base::ObjectSubType::VAN, base::ObjectSubType::BUS,
38 base::ObjectSubType::PEDESTRIAN, base::ObjectSubType::CYCLIST,
39 base::ObjectSubType::TRAFFICCONE, base::ObjectSubType::UNKNOWN,
40};

◆ MAX_CAMERA_IDX

const int apollo::perception::camera::MAX_CAMERA_IDX = 2147483647

在文件 camera_track.cc27 行定义.

◆ maxExpPower

constexpr float apollo::perception::camera::maxExpPower = 5.0f
constexpr

在文件 postprocess.h124 行定义.

◆ minExpPower

constexpr float apollo::perception::camera::minExpPower = -10.0f
constexpr

在文件 postprocess.h123 行定义.

◆ numScales

constexpr int apollo::perception::camera::numScales = 3
constexpr

在文件 postprocess.h126 行定义.

◆ object_subtype_map

const std::map<std::string, base::ObjectSubType> apollo::perception::camera::object_subtype_map
初始值:
= {
{"car", base::ObjectSubType::CAR},
{"van", base::ObjectSubType::VAN},
{"bus", base::ObjectSubType::BUS},
{"truck", base::ObjectSubType::TRUCK},
{"cyclist", base::ObjectSubType::CYCLIST},
{"motorcyclist", base::ObjectSubType::MOTORCYCLIST},
{"tricyclelist", base::ObjectSubType::TRICYCLIST},
{"pedestrian", base::ObjectSubType::PEDESTRIAN},
{"trafficcone", base::ObjectSubType::TRAFFICCONE},
}

在文件 ground_truth.cc31 行定义.

31 {
32 {"car", base::ObjectSubType::CAR},
33 {"van", base::ObjectSubType::VAN},
34 {"bus", base::ObjectSubType::BUS},
35 {"truck", base::ObjectSubType::TRUCK},
36 {"cyclist", base::ObjectSubType::CYCLIST},
37 {"motorcyclist", base::ObjectSubType::MOTORCYCLIST},
38 {"tricyclelist", base::ObjectSubType::TRICYCLIST},
39 {"pedestrian", base::ObjectSubType::PEDESTRIAN},
40 {"trafficcone", base::ObjectSubType::TRAFFICCONE},
41};

◆ spatialLUTind

std::map<base::LaneLinePositionType, int> apollo::perception::camera::spatialLUTind
初始值:
= {
{base::LaneLinePositionType::UNKNOWN, 0},
{base::LaneLinePositionType::FOURTH_LEFT, 1},
{base::LaneLinePositionType::THIRD_LEFT, 2},
{base::LaneLinePositionType::ADJACENT_LEFT, 3},
{base::LaneLinePositionType::EGO_LEFT, 4},
{base::LaneLinePositionType::EGO_CENTER, 5},
{base::LaneLinePositionType::EGO_RIGHT, 6},
{base::LaneLinePositionType::ADJACENT_RIGHT, 7},
{base::LaneLinePositionType::THIRD_RIGHT, 8},
{base::LaneLinePositionType::FOURTH_RIGHT, 9},
{base::LaneLinePositionType::OTHER, 10},
{base::LaneLinePositionType::CURB_LEFT, 11},
{base::LaneLinePositionType::CURB_RIGHT, 12}}

在文件 darkSCNN_lane_postprocessor.cc49 行定义.

49 {
50 {base::LaneLinePositionType::UNKNOWN, 0},
51 {base::LaneLinePositionType::FOURTH_LEFT, 1},
52 {base::LaneLinePositionType::THIRD_LEFT, 2},
53 {base::LaneLinePositionType::ADJACENT_LEFT, 3},
54 {base::LaneLinePositionType::EGO_LEFT, 4},
55 {base::LaneLinePositionType::EGO_CENTER, 5},
56 {base::LaneLinePositionType::EGO_RIGHT, 6},
57 {base::LaneLinePositionType::ADJACENT_RIGHT, 7},
58 {base::LaneLinePositionType::THIRD_RIGHT, 8},
59 {base::LaneLinePositionType::FOURTH_RIGHT, 9},
60 {base::LaneLinePositionType::OTHER, 10},
61 {base::LaneLinePositionType::CURB_LEFT, 11},
62 {base::LaneLinePositionType::CURB_RIGHT, 12}};

◆ THREADS_PER_BLOCK_X

const uint32_t apollo::perception::camera::THREADS_PER_BLOCK_X = 32

在文件 image_data_operations_rpp.h22 行定义.

◆ THREADS_PER_BLOCK_Y

const uint32_t apollo::perception::camera::THREADS_PER_BLOCK_Y = 32

在文件 image_data_operations_rpp.h23 行定义.