ros-perception / image_common

Common code for working with images in ROS
http://www.ros.org/wiki/image_common
125 stars 220 forks source link

Virtualize CameraInfoManager #234

Closed jdavidberger closed 2 years ago

jdavidberger commented 2 years ago

This allows custom logic for cameras that can support flash operations.

gbiggs commented 2 years ago

Can you please explain the purpose of this PR given that it doesn't provide an implementation of the new functions?

jdavidberger commented 2 years ago

As is, you can't easily reuse CameraInfoManager logic if you have a custom camera or require custom logic in terms of loading/saving the calibration. And it's unclear how you could ever implement the flash url protocol in a generic way since devices vary so widely.

So the idea is that by making all of the CameraInfoManager functions virtual is that you can support this by extending the class with code that does implement the specific logic for a specific device.

The very concrete example here is I have a depthai camera and am talking to it through ros via https://github.com/luxonis/depthai-ros/tree/main/depthai_bridge. That device has the capability of storing calibration data to the device and even exposes the set_camera_info service. If the PR goes through; it'd be very easy override the flash functions in this now-base class and have both standard CameraInfoManager behavior on top of device specific functionality.

gbiggs commented 2 years ago

There's a test failure on Debian Buster.

07:06:38 -- run_tests.py: execute commands
07:06:38   "/usr/bin/cmake" -E make_directory /tmp/ws/test_results/camera_calibration_parsers
07:06:38   /usr/bin/nosetests3 -P --process-timeout=60 /tmp/ws/src/image_common/camera_calibration_parsers/test/parser.py --with-xunit --xunit-file=/tmp/ws/test_results/camera_calibration_parsers/nosetests-parser.py.xml
07:06:38 E
07:06:39 ======================================================================
07:06:39 ERROR: Failure: ImportError (/usr/lib/x86_64-linux-gnu/libboost_python27.so.1.67.0: undefined symbol: PyString_Type)
07:06:39 ----------------------------------------------------------------------
07:06:39 Traceback (most recent call last):
07:06:39   File "/usr/lib/python3/dist-packages/nose/failure.py", line 39, in runTest
07:06:39     raise self.exc_val.with_traceback(self.tb)
07:06:39   File "/usr/lib/python3/dist-packages/nose/loader.py", line 417, in loadTestsFromName
07:06:39     addr.filename, addr.module)
07:06:39   File "/usr/lib/python3/dist-packages/nose/importer.py", line 47, in importFromPath
07:06:39     return self.importFromDir(dir_path, fqname)
07:06:39   File "/usr/lib/python3/dist-packages/nose/importer.py", line 94, in importFromDir
07:06:39     mod = load_module(part_fqname, fh, filename, desc)
07:06:39   File "/usr/lib/python3.7/imp.py", line 234, in load_module
07:06:39     return load_source(name, filename, file)
07:06:39   File "/usr/lib/python3.7/imp.py", line 171, in load_source
07:06:39     module = _load(spec)
07:06:39   File "<frozen importlib._bootstrap>", line 696, in _load
07:06:39   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
07:06:39   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
07:06:39   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
07:06:39   File "/tmp/ws/src/image_common/camera_calibration_parsers/test/parser.py", line 39, in <module>
07:06:39     from camera_calibration_parsers import readCalibration
07:06:39   File "/tmp/ws/devel_isolated/camera_calibration_parsers/lib/python3/dist-packages/camera_calibration_parsers/__init__.py", line 34, in <module>
07:06:39     exec(__fh.read())
07:06:39   File "<string>", line 1, in <module>
07:06:39 ImportError: /usr/lib/x86_64-linux-gnu/libboost_python27.so.1.67.0: undefined symbol: PyString_Type
07:06:39 
07:06:39 ----------------------------------------------------------------------
07:06:39 Ran 1 test in 0.001s
07:06:39 
07:06:39 FAILED (errors=1)
jdavidberger commented 2 years ago

I don't know that that has anything to do with this PR; it happens here too: https://build.ros.org/job/Npr_db__image_common__debian_buster_amd64/8/console

gbiggs commented 2 years ago

Yes, I think you're right, it's probably unrelated.

zgxsin commented 2 years ago

It seems the usage below is not supported anymore. Can anyone confirm that?

file://$(rospack find <package_name>)/<yaml_file_name>.yaml

I got the following error

 [CameraInfoManager::loadCalibration] : Invalid camera calibration URL

Previously i did not get such errors