SMACC2
Loading...
Searching...
No Matches
cp_table_plane.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 <cl_rgb/geometry.hpp>
18
19#include <opencv2/core.hpp>
20#include <smacc2/smacc.hpp>
21
22#include <optional>
23
24namespace cl_rgb
25{
26
27// The table: a horizontal plane of known height and extent. With it, one pixel of a
28// calibrated camera is one point in the world, and no depth image is needed.
30{
31public:
32 explicit CpTablePlane(const TableParams & params);
33 ~CpTablePlane() override;
34
35 const TableParams & params() const { return params_; }
36
37 // The world point seen at a pixel, taken to lie heightAboveTable above the table top. Zero
38 // gives the point on the table; half an object's height gives the object's middle.
39 std::optional<cv::Vec3d> pointUnderPixel(
40 const PinholeCamera & camera, double u, double v, double heightAboveTable = 0.0) const;
41
42 // the pixels of an image of the given size that see the table top, 255 inside
43 cv::Mat regionMask(const PinholeCamera & camera, const cv::Size & size) const;
44
45 // whether a point lies over the table top, inset by margin
46 bool contains(double x, double y, double margin = 0.0) const;
47
48private:
50};
51
52} // namespace cl_rgb
bool contains(double x, double y, double margin=0.0) const
cv::Mat regionMask(const PinholeCamera &camera, const cv::Size &size) const
const TableParams & params() const
CpTablePlane(const TableParams &params)
std::optional< cv::Vec3d > pointUnderPixel(const PinholeCamera &camera, double u, double v, double heightAboveTable=0.0) const