SMACC2
Loading...
Searching...
No Matches
cp_table_segmenter.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
18
19#include <opencv2/core.hpp>
20#include <smacc2/smacc.hpp>
21
22#include <mutex>
23
24namespace cl_rgb
25{
26
27// Separates what lies on the table from the table. With a reference image of the empty scene
28// it compares pixel by pixel; without one it takes the table's colour from the image itself,
29// which holds while the table fills most of its region and the objects differ from it in colour.
31{
32public:
33 explicit CpTableSegmenter(const SegmenterParams & params);
34 ~CpTableSegmenter() override;
35
36 void onInitialize() override;
37
38 void setParams(const SegmenterParams & params);
39 SegmenterParams params() const;
40
41 // the empty scene as the camera sees it; an empty image removes the reference
42 void setReference(const cv::Mat & bgr);
43 bool hasReference() const;
44
45 // 255 where the image shows something on the table, within tableMask
46 cv::Mat foreground(const cv::Mat & bgr, const cv::Mat & tableMask) const;
47
48private:
49 mutable std::mutex mutex_;
51 cv::Mat reference_;
52};
53
54} // namespace cl_rgb
SegmenterParams params() const
void setParams(const SegmenterParams &params)
void setReference(const cv::Mat &bgr)
cv::Mat foreground(const cv::Mat &bgr, const cv::Mat &tableMask) const
CpTableSegmenter(const SegmenterParams &params)