Ask Your Question
0

C++ CV::Mat.at<float>(0) in Java

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

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] = hist.at<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?

Tom,

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

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

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.total() * 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

Stats

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

Seen: 958 times

Last updated: Jun 05 '19