wg-perception / object_recognition_core

The core of object recognition, where the development now happens
48 stars 47 forks source link

Problem with my own detector.py #43

Open xMutzelx opened 8 years ago

xMutzelx commented 8 years ago

Hi community, I write my own post processing pipeline but I get some ecto/ork errors. At this point I simply try to read my training-file from the database.

The error when I try to run my detection pipeline:

Traceback (most recent call last):
  File "/home/marcel/catkin_ws/src/object_recognition_core/apps/detection", line 24, in <module>
    run_plasm(args, plasm)
  File "/opt/ros/indigo/lib/python2.7/dist-packages/ecto/opts.py", line 85, in run_plasm
    sched.execute(options.niter)
ecto.CellException:            exception_type  CellException
[cell_name] = pipeline1

[cell_type] = ecto::py::BlackBox

[function_name] = process_with_only_these_inputs

[type] = std::runtime_error

[what] =            exception_type  CellException
[cell_name] = <class 'object_recognition_colorhist.colorhist_detection.ModelReader'>

[type] = boost::exception_detail::clone_impl<ecto::except::FailedFromPythonConversion>

[what] = FailedFromPythonConversion

[when] = Copying out to object_id

My Trainer is working fine and it is also reading/writing some files from the database. I think the error is in my detection.py script. This is my detection.py script:

from ecto import BlackBoxCellInfo as CellInfo, BlackBoxForward as Forward
from object_recognition_core.db import Document, Documents
from ecto_opencv import calib, features2d, highgui
from ecto_opencv.features2d import FeatureDescriptor
from object_recognition_core.pipelines.detection import DetectorBase
from object_recognition_colorhist import colorhist_detection
import ecto
from ecto import BlackBoxCellInfo as CellInfo, BlackBoxForward as Forward

class ColorHistDetector(ecto.BlackBox, DetectorBase):
    def __init__(self, *args, **kwargs):
        print "test0"
        ecto.BlackBox.__init__(self, *args, **kwargs)
        DetectorBase.__init__(self)

    @staticmethod
    def declare_cells(p):

        cells = {'json_db': CellInfo(ecto.Constant),
                 'object_id': CellInfo(ecto.Constant),
                 'model_reader': CellInfo(colorhist_detection.ModelReader),
                 'detector' : CellInfo(colorhist_detection.Detector)} 
        return cells

    @classmethod
    def declare_forwards(cls, _p):
        p = {'json_db': [Forward('value', 'json_db')],
             'object_id': [Forward('value', 'object_id')]}
        i = {}
        o = {'detector': [Forward('pose_results')]}

        return (p,i,o)

    @classmethod
    def declare_direct_params(self, p):
        p.declare('json_object_ids', 'The ids of the objects to find as a JSON list or the keyword "all".', 'all')

    def connections(self, p):
        connections = [ self.json_db[:] >> self.model_reader['json_db'],
        self.object_id[:] >> self.model_reader['object_id'] ]
       # connections += [ self.model_reader['colorValues'] >> self.detector['colorValues'] ]

        return connections

My very simple detection.ros.ork configuration file:

# info about the db
pipeline1:
  type: ColorHistDetector
  module: object_recognition_colorhist
  parameters:
    object_ids: "all"
    db:
      type: 'CouchDB'
      root: 'http://localhost:5984'
      collection: 'object_recognition'

In my understanding 'object_id': [Forward('value', 'object_id')] contains no valid data but I might be wrong. I am working with Ubuntu 14.04 and Ros Indigo. Thank you very much.