java - OpenCV video capture not loading -
i trying load webcam on jpanel using java not working. new java opencv. code not showing error not running.
this java code:
public void run(){ synchronized (this) { while(true){ if (websource.grab()) { system.out.println("err"); try { websource = new videocapture(0); websource.retrieve(frame); graphics g = webcampanel.getgraphics(); facedetector.detectmultiscale(frame, facedetections); (rect rect : facedetections.toarray()) { // system.out.println("ttt"); core.rectangle(frame, new point(rect.x, rect.y), new point(rect.x + rect.width, rect.y + rect.height), new scalar(0, 255,0)); } highgui.imencode(".bmp", frame, mem); image im = imageio.read(new bytearrayinputstream(mem.toarray())); bufferedimage buff = (bufferedimage) im; if (g.drawimage(buff, 0, 0, getwidth(), getheight()-150 , 0, 0, buff.getwidth(), buff.getheight(), null)) { if (runnable == false) { system.out.println("paused ..... "); this.wait(); } } } catch (exception ex) { system.out.println("error"); } }else{ system.out.println("error"); } } } }
this code taken youtube tutorial. code use start , stop button use webcam. in case, dont want use button start webcam. want webcam run once program started. can me on this.
Comments
Post a Comment