Stop process of webcam in java netbeans -
i want capture image using available webcam. have accessed webcam couldn't stop webcam process. want stop webcam process using stop button. how can accomplish this? code:
public component componen() throws ioexception , noplayerexception, cannotrealizeexception { component comp_video; medialocator loo = new medialocator("vfw://0"); try { broadcast = manager.createrealizedplayer(loo); } catch (ioexception ex) { logger.getlogger(capturimage.class.getname()).log(level.severe, null, ex); } catch (noplayerexception ex) { logger.getlogger(capturimage.class.getname()).log(level.severe, null, ex); } catch (cannotrealizeexception ex) { logger.getlogger(capturimage.class.getname()).log(level.severe, null, ex); } broadcast.start(); if((comp_video = broadcast.getvisualcomponent()) != null) { comp_video.setsize(321,228); return comp_video; } else { return null; } } public void capture_image() { framegrabbingcontrol grab = (framegrabbingcontrol) broadcast.getcontrol("javax.media.control.framegrabbingcontrol"); javax.media.buffer buff = grab.grabframe(); buffertoimage buffer =new buffertoimage((videoformat) buff.getformat()); img = buffer.createimage(buff); } public void set_iamge_label(final jlabel lb) { thread web = new thread(){ public void run(){ capture_image(); rectangle rect = lb.getbounds(); image img1 = img.getscaledinstance(rect.width,rect.height,image.scale_default); lb.seticon(new javax.swing.imageicon(img1)); } }; web.start(); }
Comments
Post a Comment