Tasks #1182

Add Initial OpenCV IplImage / CVMat Converters for Python

Added by S. Wrede over 11 years ago. Updated over 11 years ago.

Status:ResolvedStart date:10/01/2012
Priority:NormalDue date:
Assignee:J. Wienke% Done:

100%

Category:pythonEstimated time:4.00 hours
Target version:Robotics Service Bus - rsb-0.7

Description

Or whatever the corresponding type in Python is.

cf. http://opencv.willowgarage.com/wiki/PythonInterface

Associated revisions

Revision b2078765
Added by J. Wienke over 11 years ago

Initial python project for rst converters with dummy contents

refs #1182

Revision e0cecda2
Added by J. Wienke over 11 years ago

Initial python project for rst converters with dummy contents

refs #1182

Revision a8caa9f6
Added by J. Wienke over 11 years ago

Provide a simple roundtrip test for the IplimageConverter.

This test only checks a single format so far and several assumptions need to be removed later.

refs #1182

Revision d93e3b2d
Added by J. Wienke over 11 years ago

Provide a simple roundtrip test for the IplimageConverter.

This test only checks a single format so far and several assumptions need to be removed later.

refs #1182

Revision fb583363
Added by J. Wienke over 11 years ago

For the moment, state the assumptions.

We have to remove them later, but so far we can live with simple BGR images.

refs #1182

Revision 7fabc88b
Added by J. Wienke over 11 years ago

For the moment, state the assumptions.

We have to remove them later, but so far we can live with simple BGR images.

refs #1182

Revision 7296cd27
Added by J. Wienke over 11 years ago

State missing type assumption in serialize mthod of IplimageConverter.

Added an assert statement.

refs #1182

Revision 0ae4a8e1
Added by J. Wienke over 11 years ago

State missing type assumption in serialize mthod of IplimageConverter.

Added an assert statement.

refs #1182

Revision 7ff005e1
Added by J. Wienke over 11 years ago

Merge branch 'pythonconverters' into 0.7

Conflicts:
cpp/cpack/CPackDebianConfig.cmake

refs #1182

History

#1 Updated by J. Wienke over 11 years ago

  • Status changed from New to In Progress

#2 Updated by J. Wienke over 11 years ago

Basic roundtrip is working in my private branch. However, only for BGR images. gstreamer sends YUV422 and I could not find a way to instruct gstreamer to send something different, because for YUV422 there is no cvCvtColor operator to use. So I would have to code the conversion in python. This will get horribly slow.

Jan, do you know a way to send RGB images with a gstreamer pipeline? I tried using ffmpegcolorspace and a video element afterwards, but the results were somehow wrong and definitely not a BGR or RGB image.

#3 Updated by J. Moringen over 11 years ago

I used

gst-launch-0.10 videotestsrc ! video/x-raw-rgb ! rsbvideosink scope=/

and the logger said

Payload (RST.VISION:IMAGE)
  #<IMAGE {100A02AB23}>
    Data      : 0000 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
                0018 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
                0030 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
                ... [omitting 153,528 of 153,600 octets]
    Width     : 320
    Height    : 240
    Channels  : 3
    Depth     : DEPTH-8U
    Color-Mode: COLOR-RGB
    Data-Order: DATA-INTERLEAVED

#4 Updated by J. Wienke over 11 years ago

This is not supported by most cheap webcams.

#5 Updated by J. Moringen over 11 years ago

Johannes Wienke wrote:

This is not supported by most cheap webcams.

Since the question was

do you know a way to send RGB images with a gstreamer pipeline?

I though, RSB images were required only for testing purposes.

Why is the following not possible?

gst-launch-0.10 WEBCAMSOURCE ! ffmpegcolorspace ! video/x-raw-rgb ! rsbvideosink scope=/

#6 Updated by J. Wienke over 11 years ago

Payload (RST.VISION:IMAGE)
  #<IMAGE {100B240493}>
    Data      : 0000 CC 9C ED 9C 0E AD ED AC AE A4 CE AC 2F AD 2F AD 30 AD AE 9C 0F AD EF AC 0F 
    0019 AD CE A4 8C 9C AD A4 10 A5 10 A5 92 9D 71 9D 50 95 30 95 0F 95 2F 9D 4F 9D 
    0032 2F 9D 0F A5 EE 9C 6D 94 CF A4 30 AD 30 AD ... [omitting 2,621,376 of 2,621,440 octets]
    Width     : 1280
    Height    : 1024
    Channels  : 3
    Depth     : DEPTH-8U
    Color-Mode: COLOR-RGB
    Data-Order: DATA-INTERLEAVE

My webcam definitely does not support 1280x1024 and images look completely broken.

#7 Updated by J. Wienke over 11 years ago

Ok, I can workaround this by using the rsb video sender. But I would have liked to prevent that hacky thing from leaking into the isy project.

#8 Updated by J. Moringen over 11 years ago

@Johannes: Can you please post the pipeline which triggers the bug?

Or maybe file a bug in RSB GStreamer Integration.

#9 Updated by J. Wienke over 11 years ago

gst-launch-0.10 v4l2src ! ffmpegcolorspace ! video/x-raw-rgb, width=640, height=480 ! rsbvideosink scope=/video

#10 Updated by J. Moringen over 11 years ago

I think, I found the bug in RSB GStreamer Integration.

#11 Updated by J. Moringen over 11 years ago

See #1194. I tried to commit a fix, but the RSB GStreamer Integration repository seems to be read-only :(

#12 Updated by J. Wienke over 11 years ago

we could use this as an opportunity to migrate to GIT ;)

#13 Updated by J. Wienke over 11 years ago

  • % Done changed from 0 to 50

I have added my initial version to the pythonconverters branch. Can someone please have a look at this. If it is fine, we can merge this back to master and 0.7.

#14 Updated by J. Moringen over 11 years ago

I looked at the branch and I did not see any problems. However, I would prefer at least some cleanup before merging this into master.

Unrelated note: I think, Python docstrings use """...""", not '''...'''.

#15 Updated by J. Wienke over 11 years ago

Which clean up do you mean? I don't have much time to implement all the other formats.

#16 Updated by J. Moringen over 11 years ago

When I looked at the code, there were lots of TODO, little error handling and few comments.

Maybe we can make a branch for ISY now and merge it into master when we manage to finish it?

#17 Updated by J. Wienke over 11 years ago

The TODOs exist, apart from a few more formats implemented in C++, in same way there.

For error handling we do not have a specific exception class in python as far as I remember. So the assertion error should do the desired thing to my mind.

#18 Updated by J. Wienke over 11 years ago

  • Status changed from In Progress to Resolved
  • Target version changed from rsb-0.9 to rsb-0.7
  • % Done changed from 50 to 100

I have merged the feature branch to 0.7. We can see what we do with that branch for 0.8 some time later.

Also available in: Atom PDF