OpenCV 2.4.4 Java - Grab Webcam picture/stream (OSX) -
i'm new in world of stackoverflow , in opencv programming. i've made projects opencv bindings java (the opencv.org officials, not javacv), object recognition through orb , surf features, working images. ok. i'm moving object recognition in video streams. want grab stream webcam , apply object recognition. i'm not java guru, found in opencv videocapture class, i'm not able obtain pictures camera.
i'm running project in eclipse opencv 2.4.4 bindings, in osx mountain lion.
the result in console:
hello, opencv camera ok? frame obtained captured frame width 0 invalid memory access of location 0x7fae00000000 rip=0x7fff8b4c5263
the code:
import org.opencv.core.mat; import org.opencv.highgui.highgui; import org.opencv.highgui.videocapture; public class webcam { public static void main (string args[]){ system.out.println("hello, opencv"); // load native library. system.loadlibrary("opencv_java244"); videocapture camera = new videocapture(0); camera.open(0); //useless if(!camera.isopened()){ system.out.println("camera error"); } else{ system.out.println("camera ok?"); } mat frame = new mat(); //camera.grab(); //system.out.println("frame grabbed"); //camera.retrieve(frame); //system.out.println("frame decoded"); camera.read(frame); system.out.println("frame obtained"); /* no difference camera.release(); */ system.out.println("captured frame width " + frame.width()); highgui.imwrite("camera.jpg", frame); system.out.println("ok"); } }
the problem camera need time initialize. i've added
thread.sleep(1000);
after
videocapture camera = new videocapture(0);
Comments
Post a Comment