Detection¶
To implement a detection pipeline runnable with the object recognition infrastructure you will need a Python script that implements a plasm for your pipeline. To ease the implementation, we describe a simple way way to retrieve models from the database, as well as the output format of the pipeline.
Python Plasm¶
Your pipeline has to provide an implementation of the object_recognition_core.pipelines.detection.DetectionPipeline
class to be fully integrated with object recognition infrastructure:
-
class
object_recognition_core.pipelines.detection.
DetectorBase
(do_check_object_ids=True, do_check_db=True)[source]¶ This is a base class for a detection pipeline: you don’t need to have your pipeline cell inherit from that class but if you do, it will make sure that its inputs/outputs fit the ORK standard (which is good if you want to interact with the official ORK pipelines). You need to call the BlackBox constructor in your __init__ first and then this function. Typically, your __init__ is
>>> class Foo(ecto.BlackBox, DetectorBase): >>> def __init__(self, *args, **kwargs): >>> ecto.BlackBox.__init__(self, *args, **kwargs) >>> DetectorBase.__init__(self)
By providing so, after parsing the config file, the detection script will be able to find/load you cell when present on the PYTHONPATH.
Database Cell¶
If you are using the predefined ModelWriter for training, you will also want to use our ModelReader for simplicity.
Step 1¶
The cell is bit different from the ModelWriter as it reads several models at once. It has to inherit from
db::bases::ModelReaderImpl
. An example implementation is:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | struct MyAwesomeModelReaderImpl: public db::bases::ModelReaderImpl
{
public:
// This function gives you db_documents for each model from which you can extract the information you want and
// store it locally (maybe in a search structure)
void
ParameterCallback(const Documents & db_documents)
{
// Stacking the models, or building a search structure ...
}
// The next 4 functions are the standard ecto cells ones
static void
declare_params(ecto::tendrils& params)
{
}
static void
declare_io(const ecto::tendrils& params, ecto::tendrils& inputs, ecto::tendrils& outputs)
{
}
void
configure(const ecto::tendrils& params, const ecto::tendrils& inputs, const ecto::tendrils& outputs)
{
}
virtual int
process(const ecto::tendrils& inputs, const ecto::tendrils& outputs)
{
// Doing some awesome matching or just passing the models to the output
return ecto::OK;
}
};
|
The ParameterCallback
function gets from the model everything that makes it specific. Please refer to ModelWriter
for how to get this data
Step 2¶
Very important, you need to actually define a type for your cell based on ModelReaderBase. Something like this suffices:
typedef db::bases::ModelReaderBase<MyAwesomeModelReaderImpl> MyAwesomeModelReaderCell;
Sink¶
You can output results to the console or to a CSV file.
That is all you can output to if you don’t use ROS.
If you want to use the ROS publisher that outputs object recognition messages, you need to have your recognition pipeline have the following output tendrils:
object_ids: a vector of Object ids Rs: a vector of cv::Mat, each representing the pose rotation of a matching object ts: a vector of cv::Mat, each representing the pose translation of a matching object