waggle-sensor / pywaggle

Python SDK for integrating plugins with Waggle.
Other
6 stars 8 forks source link

Allows bgr2rgb conversion in data-shim #11

Closed gemblerz closed 4 years ago

gemblerz commented 4 years ago

OpenCV provides BGR images natively. Some machine learning models are trained against RGB images and it will be much better if the data-shim supports bgr2rgb conversion for such models. Since open_data_source uses data-config.json, users need to declare bgr2rgb: false in args section inside the file. By default, I propose bgr2rgb conversion is enabled. An example is below,

[
{
    "name": "Bottom Camera Video",
    "match": {
        "id": "image_bottom",
        "type": "camera/video",
        "orientation": "bottom",
        "resolution": "800x600"
    },
    "handler": {
        "type": "image",
        "args": {
            "url": "http://playback:8090/bottom/image.jpg",
            "bgr2rgb": false
        }
    }
}
]
gemblerz commented 4 years ago

"pixel_format" makes sense to me. I am going to make the change before merging this.

seanshahkarami commented 4 years ago

Sounds good - yeah, it's just to future proof it a bit more. Feel free to merge after updating it.

gemblerz commented 4 years ago

The bgr2rgb parameter is replaced with pixel_format,

[
{
    "name": "Bottom Camera Video",
    "match": {
        "id": "image_bottom",
        "type": "camera/video",
        "orientation": "bottom",
        "resolution": "800x600"
    },
    "handler": {
        "type": "image",
        "args": {
            "url": "http://playback:8090/bottom/image.jpg",
            "pixel_format": "rgb"
        }
    }
}
]

Nevertheless, the default is set to rgb therefore no need to specify if rgb images needed.

As of now, bgr and rgb are the only conversions supported.