SMACC2
Loading...
Searching...
No Matches
geometry.hpp
Go to the documentation of this file.
1// Copyright 2026 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <opencv2/core.hpp>
18
19#include <optional>
20
21namespace cl_rgb
22{
23
24// A pinhole camera at a known pose. The optical frame follows the ROS convention:
25// z forward, x right, y down. Lengths in metres, image coordinates in pixels.
27{
28 double fx = 1.0;
29 double fy = 1.0;
30 double cx = 0.0;
31 double cy = 0.0;
32 cv::Matx33d rotation = cv::Matx33d::eye(); // optical frame to world frame
33 cv::Vec3d position{0.0, 0.0, 0.0}; // of the optical centre, world frame
34
35 // direction, in the world frame, of the ray through a pixel (not normalized)
36 cv::Vec3d rayDirection(double u, double v) const;
37
38 // pixel of a world point; nothing when the point is behind the camera
39 std::optional<cv::Point2d> project(const cv::Vec3d & point) const;
40
41 // where the ray through a pixel meets the horizontal plane at height z of the world
42 // frame; nothing when the ray does not reach the plane in front of the camera
43 std::optional<cv::Vec3d> pixelToPlane(double u, double v, double z) const;
44
45 // maps homogeneous pixels (u, v, 1) to homogeneous plane coordinates (x, y, 1) at height z
46 cv::Matx33d imageToPlaneHomography(double z) const;
47};
48
49// A horizontal table top in the world frame.
51{
52 double height = 0.0; // m, z of the table top
53 double xMin = -0.5; // m
54 double xMax = 0.5;
55 double yMin = -0.5;
56 double yMax = 0.5;
57};
58
59} // namespace cl_rgb
cv::Matx33d rotation
Definition geometry.hpp:32
std::optional< cv::Vec3d > pixelToPlane(double u, double v, double z) const
Definition geometry.cpp:35
cv::Matx33d imageToPlaneHomography(double z) const
Definition geometry.cpp:50
cv::Vec3d rayDirection(double u, double v) const
Definition geometry.cpp:20
std::optional< cv::Point2d > project(const cv::Vec3d &point) const
Definition geometry.cpp:25