PS3EYEDriver icon indicating copy to clipboard operation
PS3EYEDriver copied to clipboard

debayer filter fails for vertically flipped images

Open bakercp opened this issue 8 years ago • 1 comments

// horz, vert
_cam->setFlip(false, false);

blank_skitch_document

// horz, vert
_cam->setFlip(false, true);

blank_skitch_document

The filter works correctly for horizontally flipped images.

This is likely because the pattern looks different upside-down.

 G R G R G R
 B G B G B G
 G R G R G R
 B G B G B G

@rovarma Thanks for your work on this! I'm updating https://github.com/bakercp/ofxPS3EyeGrabber/

bakercp avatar Dec 13 '17 03:12 bakercp

Just a small followup for reference. Since opencv is a default included addon for openFrameworks I'm just using cv::demosaicing to do my conversions as it is hardware optimized, etc. For pixels with no vertical flip I use

        if (_pixelFormat == OF_PIXELS_GRAY)
        {
            code = vFlip ? cv::COLOR_BayerRG2GRAY : cv::COLOR_BayerGB2GRAY;
        }
        else
        {

The difference is just RG vs GB (the default debayering function in this library is hard-coded to GB). After choosing the right conversion type, I pass my pixels like this:

        cv::demosaicing(ofxCv::toCv(_rawCameraPixels),
                        ofxCv::toCv(_pixels),
                        code);

bakercp avatar Dec 14 '17 00:12 bakercp