CV_16F support for OpenCV Java.

asked 2018-12-22 05:09:41 -0500

Alex.A gravatar image

I see that in OpenCv 4.0.0 version includes support for half float type. It looks like it is not available in Java wrapper. In addition to that, the value assigned to the CV_16F - 7 is already used by other enum value: CV_USRTYPE1 So my question is that assuming that I change the CvType the following way, would it be sufficient to use half floats from java? :

// type depth constants
public static final int
        CV_8U = 0, CV_8S = 1,
        CV_16U = 2, CV_16S = 3,
        CV_32S = 4,
        CV_32F = 5,
        CV_64F = 6,
        CV_16F = 7;

// predefined type constants
public static final int
        CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4),
        CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4),
        CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4),
        CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4),
        CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4),
        CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4),
        CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4)
        // Half Float type:
        CV_16FC1 = CV_16FC(1), CV_16FC2 = CV_16FC(2), CV_16FC3 = CV_16FC(3), CV_16FC4 = CV_16FC(4);

public static final int CV_16FC(int ch) {
    return makeType(CV_16F, ch);
}
edit retag flag offensive close merge delete

Comments

if you still have CV_USRTYPE1 in the c++ code there, then chances are low (you'd need to binary match the c++ defs). and indeed, in the current master branch, the java definitions were not updated.

please rather update to latest master branch, where this was changed , then your idea might work as intended.

however note, that support for CV_16F is very sparse atm, it's only used internally inside the dnn module (for compression), afaik.

just curious, what would be your "use-case" for this ?

berak gravatar imageberak ( 2018-12-22 05:15:17 -0500 )edit