Ask Your Question

tuva's profile - activity

2017-07-09 14:27:05 -0600 received badge  Student (source)
2013-06-02 21:23:43 -0600 commented question Negative Values When Getting Pixels in Java API

You can fix this by doing an "& 0xFF" with each entry.

2013-05-07 22:42:04 -0600 received badge  Editor (source)
2013-05-07 22:41:11 -0600 asked a question Matrix not displayed in ant example (Java Tutorial)

Just installed OpenCV (2.4.9). Followed the ant example in the Java tutorial using the files already given. Doesn't seem like I encountered any problems. That said, the matrix isn't printed like in the example. Instead, nothing gets printed. Output:

Buildfile: /home/username/opencv/samples/java/ant/build.xml

clean:
   [delete] Deleting directory /home/username/opencv/samples/java/ant/build

compile:
    [mkdir] Created dir: /home/username/opencv/samples/java/ant/build/classes
    [javac] Compiling 1 source file to /home/username/opencv/samples/java/ant/build/classes

jar:
    [mkdir] Created dir: /home/username/opencv/samples/java/ant/build/jar
      [jar] Building jar: /home/username/opencv/samples/java/ant/build/jar/SimpleSample.jar

run:
     [java] Welcome to OpenCV 2.4.9.0
     [java] OpenCV Mat: Mat [ 5*10*CV_8UC1, isCont=true, isSubmat=false, nativeObj=0x7fd5581a5270, dataAddr=0x7fd5581a5330 ]
     [java] OpenCV Mat data:
     [java] 

rebuild-run:

BUILD SUCCESSFUL 
Total time: 1 second

Is there something wrong / new with the dump function? I didn't encounter this problem the last time I installed OpenCV (2.4.4). Nothing seems different looking at the API. I am using Java Oracle 7 and running Arch Linux. I was able to output other functions like m.cols() fine.

Here's the SimpleSample.java file for reference:

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.CvType;
import org.opencv.core.Scalar;

class SimpleSample {

  static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }

  public static void main(String[] args) {
    System.out.println("Welcome to OpenCV " + Core.VERSION);
    Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
    System.out.println("OpenCV Mat: " + m);
    Mat mr1 = m.row(1);
    mr1.setTo(new Scalar(1));
    Mat mc5 = m.col(5);
    mc5.setTo(new Scalar(5));
    System.out.println("OpenCV Mat data:\n" + m.dump());
  }
}
2013-03-05 15:31:55 -0600 received badge  Scholar (source)
2013-03-04 21:31:56 -0600 asked a question Negative Values When Getting Pixels in Java API

The pixel values I'm getting are negative.

Mat src = Highgui.imread("image.png", Highgui.CV_LOAD_IMAGE_COLOR);
byte[] onePixelData = new byte[3]; 
src.get(x, y, onePixelData);
System.out.println(Arrays.toString(onePixelData)); // outputs [-5, -102, 5]

Am I doing something wrong or is it because Java doesn't support unsigned data types? What's the best way to fix this?

2012-12-18 22:30:10 -0600 received badge  Supporter (source)