Ask Your Question

C++<float>(0) in Java

asked 2019-06-05 08:52:13 -0500

I'm currently converting the code from this answer(How to make auto-adjustments(brightness and contrast) for image Android Opencv Image Correction)

In this answer, the following statement is used:

accumulator[0] =<float>(0);

After reading some documentation and code snippets I can't seem to figure out how I should translate this statement to Java.

Does someone know how this would be written in Java?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-06-05 12:22:58 -0500

Eduardo gravatar image

See the OpenCV tutorials for some Java code, example here.

In Java, you have to retrieve the whole buffer, something like:

    float[] bHistData = new float[(int) ( * bHist.channels())];
    bHist.get(0, 0, bHistData);

To iterative over a HxWxC stored as a 1D-buffer, it should be something like this (pseudo-code):

for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
        for (int c = 0; c < C; c++)
            buf[i*W*C + j*C + c] = 0;
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-06-05 08:52:13 -0500

Seen: 245 times

Last updated: Jun 05 '19