|
|
NVIDIA DeepStream SDK API Reference
|
9.2 Release
|
Go to the documentation of this file.
18 #ifndef NVMULTIOBJECTTRACKERLIB_OBJECTMODELPROJECTOR_HPP_
19 #define NVMULTIOBJECTTRACKERLIB_OBJECTMODELPROJECTOR_HPP_
24 #include <opencv2/opencv.hpp>
27 #include "modules/utility/dataTypes.hpp"
28 #include "modules/utility/debug_common.hpp"
29 #include "modules/NvMultiObjectTracker/NvMultiObjectTracker_common.hpp"
30 #include "modules/NvMultiObjectTracker/NvTrackerParams.hpp"
33 template <
typename K,
int N,
int M>
34 using Matrix = Eigen::Matrix<K, N, M>;
165 void read(
const YAML::Node &fn)
override;
260 const Eigen::Vector2d pt_img_head,
const NvMOTClassId classId,
const int targetInd
270 const Eigen::Vector2d pt_img_waist,
const NvMOTClassId classId,
const int targetInd
280 const Eigen::Vector2d pt_img_head,
const NvMOTClassId classId,
const int targetInd
297 const Eigen::Vector2d pt_img_head,
const Eigen::Vector2d pt_img_waist,
299 const NvMOTClassId classId,
float conf_head,
float conf_waist,
float conf_foot
310 const Eigen::Vector2d pt_img_head,
const Eigen::Vector2d pt_img_waist,
322 const Eigen::Vector2d pt_img_head,
const Eigen::Vector2d pt_img_foot,
333 const Eigen::Vector2d pt_world_feet,
const NvMOTClassId classId,
const int targetInd
341 const std::vector<Eigen::Vector2d>& pt_world_feet_list
351 const Eigen::Vector2d imgWaistPt,
const NvMOTClassId classId,
const int targetInd
361 const Eigen::Vector2d imgHeadPt,
const NvMOTClassId classId,
const int targetInd
371 const Eigen::Vector2d imgWaistPt,
const NvMOTClassId classId,
const int targetInd
381 const Eigen::Vector2d imgWaistPt,
const NvMOTClassId classId,
const int targetInd
391 const Eigen::Vector2d imgWaistPt,
const NvMOTClassId classId,
const int targetInd
401 const Eigen::Vector2d imgFeetPt,
const NvMOTClassId classId,
const int targetInd
411 const Eigen::Vector2d pt_world_feet,
const NvMOTClassId classId,
const int targetInd
421 const Eigen::Vector2d pt_world_feet,
const NvMOTClassId classId,
const int targetInd
444 const Eigen::Vector2d pt_world_feet,
const float radius
499 std::cout <<
"[ObjectModelProjector] Set target model for classId " << classId
581 std::cout <<
"[ObjectModelProjector] Warning: No model defined for classId " << classId
582 <<
", using first available model" << std::endl;
603 std::cout <<
"[ObjectModelProjector] Warning: No homography for classId " << classId
604 <<
", using first available" << std::endl;
625 const Eigen::Vector2d pt_img_waist,
const NvMOTClassId classId,
const int targetInd
635 const Eigen::Vector2d pt_img_head,
const NvMOTClassId classId,
const int targetInd
645 const Eigen::Vector2d pt_img_feet,
const NvMOTClassId classId,
const int targetInd
655 const Eigen::Vector2d pt_world_feet,
const NvMOTClassId classId,
const int targetInd
672 #endif // NVMULTIOBJECTTRACKERLIB_OBJECTMODELPROJECTOR_HPP_
Eigen::Vector2d m_pix2cam_offset
Shifts corner-origin pixels to the optical center for projectionMatrix_3x4.
const TargetHomography & getDefaultHomographyMatByClass(const NvMOTClassId classId)
Return the default homographies for a class.
const Eigen::Vector2d getCamWaistPtFromCamHeadPt(const Eigen::Vector2d imgHeadPt, const NvMOTClassId classId, const int targetInd)
Map an image head point to the corresponding image waist point.
std::string m_resolvedCameraModelFilepath
Resolved camera model filepath for this stream.
bool m_keepDetBboxForInitEstimation
Keeps the detector box for initial association instead of the recovered-model box.
std::vector< std::string > m_cameraModelFilepath
Stores camera-model paths indexed by stream.
Store a projected three-dimensional bounding box and its corners.
HomographyMatrix m_H_ground_inv
Inverse of ground plane homography.
const Eigen::Vector2d getWorldFeetPtOnGroundFromCamFeetPt(const Eigen::Vector2d imgFeetPt, const NvMOTClassId classId, const int targetInd)
Recover world-ground feet coordinates from an image feet point.
Eigen::Vector2d pt_world_feet
The feet position on the floor in world coordinate system.
const Eigen::Vector2d getWorldFeetPtOnGroundFromCamWaistPt(const Eigen::Vector2d imgWaistPt, const NvMOTClassId classId, const int targetInd)
Recover world-ground feet coordinates from an image waist point.
void queryParams(NvMOTQuery ¶msQuery)
Populate tracker query capabilities from projector configuration.
NvMOTClassId m_targetClassId
Projector's current target model class ID.
double Ty
Specifies camera translation along the Y axis.
std::map< std::string, std::string > m_cameraModelFilepathMap
Stores camera-model paths keyed by sensor name.
std::map< NvMOTClassId, Model3DInfo > m_defaultModelByClass
Each class's object model.
float height
Specifies model height.
RecoveredObjModel & operator=(RecoveredObjModel &&) noexcept=default
Move-assign a recovered object model.
CameraMatrix m_ProjMat_World2Cam
Stores the world-to-camera projection matrix.
float getTargetHeight() const
Return the current target-model height.
@ CYLINDER
Models the target as a cylinder.
void setTargetHeight(float height, float confidence, bool force=false)
Update target-model height when confidence permits.
Eigen::Matrix2d computeGroundCovariance(const Eigen::Vector2d &pixel_pt, float pixel_sigma)
Compute ground plane position covariance from pixel uncertainty using Jacobian.
const NvMotDataTypes::Rect2f getBboxOfProjectedCylinderFromImgFeet(const Eigen::Vector2d pt_img_head, const NvMOTClassId classId, const int targetInd)
Project a cylinder bounding box from an image-space feet point.
double Tx
Specifies camera translation along the X axis.
double H_Camera2MappedImage_Scale
Stores the mapped-image scale.
HomographyMatrix Waist2Feet
Maps waist image points to feet image points.
IntrinsicMatrix m_K
Intrinsic matrix.
RecoveredObjModel()=default
Construct an empty recovered object model.
HomographyMatrix CamOpticalCenter2WorldFeetPlane
Maps the camera optical-center plane to the world feet plane.
Eigen::Vector2d computeHeightAndWorldFeetFromHeadAndFoot(const Eigen::Vector2d pt_img_head, const Eigen::Vector2d pt_img_foot, const TrackerIndex &targetInd, const NvMOTClassId classId)
Estimate target height and world feet position from image head and foot points.
RotationMatrix m_R
Rotation matrix (world to camera).
TargetHomography m_targetHomographyMat
Homography matrices for head, waist, and feet planes composed from the projection matrix.
const Eigen::Vector2d projectWorldPt2ImgPt(const Eigen::Vector3d pt_world)
Project a world-space point into image coordinates.
RotationMatrix m_R_T
Transpose of rotation matrix.
Matrix< double, 3, 1 > TranslationMatrix
3x1 Translation matrix T.
Eigen::Vector2d pt_img_center
The refined image coordinate of the human waist (i.e., center of bbox).
HomographyMatrix m_H_ground
Ground-plane homography, independent of target height.
float visibility
Stores the visible fraction after occlusion and image-border cropping.
double focalLength
Specifies the camera focal length.
double roll
Specifies roll in degrees.
RecoveredObjModel getRecoveredObjectModelFromBbox(const NvMOTObjToTrack *detObj, const NvMOTFrameNum frameNum, const int targetInd, const bool isInitEstimation)
Recover an object model from a detector bounding box.
std::vector< std::vector< Proj3DBboxInfo > > m_externalProj3DBboxInfo
Store projected 3D bounding box info for all frames in the stream.
TranslationMatrix m_camLocation_World
Camera position in world coordinate system.
Eigen::Vector2d H_Camera2MappedImage_posOffset
Stores the mapped-image position offset.
NvTrackerParamsObjectModelProjector m_params
Config params for target management.
@ BBOX3D
Models the target as a three-dimensional bounding box.
const bool getOutputFootLocation()
Return whether foot-location output is enabled.
bool importCameraModelInfo(const std::string filename)
Import camera-model calibration from a YAML file.
std::vector< Eigen::Vector2f > projCorners
Bottom four points, and top four points.
NvMotDataTypes::Rect2f bbox
The refined bbox using the projected cylindrical model.
HomographyMatrix WorldWaistPlane2CamOpticalCenter
Maps the world waist plane to the camera optical-center plane.
Eigen::Vector3d m_r3
Third row of R^T (for ground plane intersection).
bool isTargetModelValid(TrackerIndex targetInd, NvMOTClassId classId)
Return whether the current target model is valid for a target.
const NvMotDataTypes::Rect2f getBboxOfProjectedCylinderFromImgHead(const Eigen::Vector2d pt_img_head, const NvMOTClassId classId, const int targetInd)
Project a cylinder bounding box from an image-space head point.
std::string order
Specifies the rotation-matrix axis order.
RecoveredObjModel getRecoveredObjectModelWithAdaptiveHeight(const Eigen::Vector2d pt_img_head, const Eigen::Vector2d pt_img_waist, const Eigen::Vector2d pt_img_foot, const NvMotDataTypes::Rect2f &bbox, const TrackerIndex &targetInd, const NvMOTClassId classId, float conf_head, float conf_waist, float conf_foot)
Get recovered 3D cylinder model with dynamic height from pose keypoints.
void read(const YAML::Node &fn) override
Update object-model projector parameters from a YAML node.
bool isTargetVisibleInImage(const Eigen::Vector2d &pt_world_feet, float targetHeight)
Check if any point of a vertical target (from feet to head) projects into the camera FOV.
float getHeightConfidence() const
Return the current height-estimation confidence.
float distFromCam
Stores the distance from the camera.
std::vector< Eigen::Vector2d > calculateProjectedCylinderFromImgHead(const Eigen::Vector2d pt_img_head, const NvMOTClassId classId, const int targetInd)
Project a cylinder from an image-space head point.
std::map< NvMOTClassId, TargetHomography > m_defaultHomographyMatByClass
Stores default target homographies by class.
const Eigen::Vector2d getCamWaistPtFromCamFeetPt(const Eigen::Vector2d imgWaistPt, const NvMOTClassId classId, const int targetInd)
Map an image feet point to the corresponding image waist point.
double yaw
Specifies yaw in degrees.
Eigen::Vector2d computeHeightAndWorldFeetFromHeadAndWaist(const Eigen::Vector2d pt_img_head, const Eigen::Vector2d pt_img_waist, const TrackerIndex &targetInd, const NvMOTClassId classId)
Estimate target height and world feet position from image head and waist points.
std::vector< std::string > m_proj3DBboxFilePath
Stores external three-dimensional bounding-box paths.
bool m_isInit
Indicates whether the projector has been initialized.
const Eigen::Vector2d getCamHeadPtFromCamWaistPt(const Eigen::Vector2d imgWaistPt, const NvMOTClassId classId, const int targetInd)
Map an image waist point to the corresponding image head point.
float m_useDefaultModelRadius
Overrides class-specific model radius when positive.
HomographyMatrix WorldHeadPlane2CamOpticalCenter
Maps the world head plane to the camera optical-center plane.
HomographyMatrix CamOpticalCenter2WorldHeadPlane
Maps the camera optical-center plane to the world head plane.
const std::string m_configFilePath
Path of the module config file.
const Eigen::MatrixXd convertYamlVec2EigenMatrixXd(YAML::Node yamlVec, const int rows, const int cols)
Convert a nested YAML sequence to an Eigen matrix.
uint m_streamInd
Index of the corresponding source stream.
bool importExternalProj3DBboxInfo(const std::string filename)
Import externally projected three-dimensional bounding boxes.
virtual ~ObjectModelProjector()
Destroy the object-model projector.
HomographyMatrix Feet2Waist
Maps feet image points to waist image points.
Eigen::Vector2d pt_img_feet
The feet position in camera image frame.
std::string m_sensorName
Sensor name of the corresponding source stream.
std::vector< Eigen::Vector2d > calculateProjectedCircleFromWorldFeet(const Eigen::Vector2d pt_world_feet, const float radius)
Project a horizontal circle centered at world-space feet coordinates.
Eigen::Matrix< T, Rows, Cols, Eigen::DontAlign > Matrix
float m_useDefaultModelHeight
Overrides class-specific model height when positive.
const bool getOutputConvexHull()
Return whether convex-hull output is enabled.
HomographyMatrix Waist2Head
Maps waist image points to head image points.
Eigen::Vector3d m_P_z_col
P[:,2] - projection matrix Z column (height update direction).
ObjectModelProjector()
Construct an uninitialized object-model projector.
Provides common loading helpers for tracker configuration parameters.
int m_debugVerboseLevel
Controls debug message verbosity.
Matrix< double, 3, 3 > IntrinsicMatrix
3x3 Intrinsic matrix: K.
Holds information about an object to be tracked.
Store object-model projector configuration parameters.
Matrix< double, 3, 3 > HomographyMatrix
3x3 Homography matrix: H.
Describe a class-specific three-dimensional target model.
Proj3DBboxInfo & operator=(Proj3DBboxInfo &&) noexcept=default
Move-assign a projected bounding-box record.
const Eigen::Vector2d getCamFeetPtFromCamWaistPt(const Eigen::Vector2d imgWaistPt, const NvMOTClassId classId, const int targetInd)
Map an image waist point to the corresponding image feet point.
std::vector< Eigen::Vector2d > calculateProjectedCylinderFromWorldFeet(const Eigen::Vector2d pt_world_feet, const NvMOTClassId classId, const int targetInd)
Project a cylinder from world-space feet coordinates.
Holds the capabilities and requirements reported by the tracker library.
const NvMotDataTypes::Rect2f getBboxOfProjectedCylinderFromImgWaist(const Eigen::Vector2d pt_img_waist, const NvMOTClassId classId, const int targetInd)
Project a cylinder bounding box from an image-space waist point.
Store plane and inter-plane homographies for a target model.
double Tz
Specifies camera translation along the Z axis.
std::vector< Eigen::Vector2d > calculateProjectedCylinderFromImgWaist(const Eigen::Vector2d pt_img_waist, const NvMOTClassId classId, const int targetInd)
Project a cylinder from an image-space waist point.
bool m_outputFootLocation
Enables foot-location output.
const Model3DInfo & getDefaultModelByClass(const NvMOTClassId classId)
Return the default three-dimensional model for a class.
Eigen::Vector3d m_H_inv_Pz
H_ground_inv * P_z_col (precomputed for Sherman-Morrison).
const NvDsObj3DBbox getWorld3DBboxFromWorldFeet(const Eigen::Vector2d pt_world_feet, const NvMOTClassId classId, const int targetInd)
Build a world-space three-dimensional bounding box from feet coordinates.
float m_minPoseConfidence
Minimum pose keypoint confidence for adaptive height estimation.
CameraInfo()
Initialize camera rotation order to YZX.
float radius
Specifies model radius.
IntrinsicMatrix m_K_inv
Inverse of intrinsic matrix.
Store geometry recovered from an object model.
HomographyMatrix CamOpticalCenter2WorldWaistPlane
Maps the camera optical-center plane to the world waist plane.
Project and recover target geometry using camera and object models.
Model3DInfo m_targetModel
Each target's object model can be different in size.
double pitch
Specifies pitch in degrees.
NvMOTClassId getTargetClassId() const
Return the current target-model class ID.
float m_eyeHeightRatio
Specifies the ratio of eye-keypoint height to total height.
const NvMotDataTypes::Rect2f getBboxOfProjectedCylinderFromWorldFeet(const Eigen::Vector2d pt_world_feet, const NvMOTClassId classId, const int targetInd)
Project a cylinder bounding box from world-space feet coordinates.
OBJ_MODEL_TYPE
Enumerate the supported object-model types.
Matrix< double, 3, 3 > RotationMatrix
3x3 Rotation matrix: R.
Holds 3D bbox information for an object.
float m_groundPlaneHeight
Specifies the world-space ground-plane height.
float m_waistHeightRatio
Specifies the ratio of hip-keypoint height to total height.
std::vector< Eigen::Vector2d > calculateProjCornersOf3DBboxFromWorldFeet(const Eigen::Vector2d pt_world_feet, const NvMOTClassId classId, const int targetInd)
Project the eight corners of a world-space three-dimensional bounding box.
Represents a two-dimensional integer size.
NvMotDataTypes::Rect2f bbox
Stores the projected bounding rectangle.
HomographyMatrix Head2Waist
Maps head image points to waist image points.
TranslationMatrix m_t
Translation vector.
Store camera calibration and image-mapping parameters.
float getMinPoseConfidence() const
Return the minimum pose-keypoint confidence.
const std::string & getSensorName() const
Return the source sensor name.
Matrix< double, 3, 4 > CameraMatrix
3x4 Camera matrix: [ R | T ].
bool m_outputConvexHull
Enables convex-hull output.
void setTargetModelForClass(NvMOTClassId classId)
Select the target model for a class ID.
RecoveredObjModel getRecoveredObjectModelFromProj3DBbox(const NvMOTObjToTrack *detObj, const NvMOTFrameNum frameNum)
Recover an object model from externally projected three-dimensional bounding-box data.
Eigen::Matrix< double, 3, 1 > Vector3d
NvMotDataTypes::Size m_srcFrameSize
Source video frame size where the bbox info is based on.
int m_maxConvexHullSize
Specifies the maximum number of convex-hull points.
std::vector< Eigen::Vector2f > convexHull
The convex hull of the human cylinder model.
Proj3DBboxInfo()=default
Construct an empty projected bounding-box record.
HomographyMatrix WorldFeetPlane2CamOpticalCenter
Maps the world feet plane to the camera optical-center plane.
void deriveDataFromCameraProjMatrix(TargetHomography &homographyMat, const Model3DInfo &humanModel)
Derive target-plane homographies from the camera projection matrix.
CameraInfo m_cameraInfo
Set camera parameters.
float heightConfidence
Confidence of height estimation (0 = default/no pose data).
bool isInitialized()
Return whether the projector has been initialized.
Renders and writes visual tracker debugging output.
const std::vector< Eigen::Vector2d > getProjectedWorldGroundPts(const std::vector< Eigen::Vector2d > &pt_world_feet_list)
Project world-ground points into image coordinates.
std::vector< Eigen::Vector2d > calculateProjectedCylinderFromImgFeet(const Eigen::Vector2d pt_img_feet, const NvMOTClassId classId, const int targetInd)
Project a cylinder from an image-space feet point.
OBJ_MODEL_TYPE m_objectModelType
Selects the object-model type.
NvTrackerParamsObjectModelProjector()
Initialize object-model projector parameters with default values.