Ask Your Question
-1

opencv mat.at<cv::Vec4b> convert to java

asked 2018-04-02 01:47:14 -0600

jhovarie gravatar image

updated 2018-04-02 01:48:00 -0600

Hello I have opencv code written on objective-c I dont know how to convert it on java..

The objective c code looks like this.

cv::Math image2 = .....

for(int x = image2.cols; x >= 0; --x){
  for(int y = 0; y < image2.rows; y++) {
     int red = image2.at<cv::Vec4b>(y,x)[0];
     int green = image2.at<cv::Vec4b>(y,x)[1];
     int blue = image2.at<cv::Vec4b>(y,x)[2];

    //to set the pixel
     //image2.at<cv::Vec4b>(y,x)[0] = 100;
     //image2.at<cv::Vec4b>(y,x)[1] = 0;
     //image2.at<cv::Vec4b>(y,x)[2] = 200;
  }
}

Any help? I need java version of this code.

edit retag flag offensive close merge delete

Comments

the c++ code is already broken (BGR vs. RGB, also is the type really RGBA or Vec4 ?)

and you should avoid any per pixel code, using openvc.

please learn the api, don't try to defeat it by writing your own loops.

berak gravatar imageberak ( 2018-07-07 10:26:54 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-07-07 09:47:48 -0600

ali hakimiyan gravatar image

in java you can use get(i,j)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-04-02 01:47:14 -0600

Seen: 919 times

Last updated: Jul 07 '18