求高手! 想用JavaCV获取摄像头图像并拍照,买的高分辨率的摄像头,可是拍出来的照片才55kb,远不及直接连电脑拍出来的效果,请教如何在java程序中调节分辨率
http://blog.csdn.net/sivyer123/article/details/22411861 这是示例程序
public class video
{
public static void main(String[] args) throws Exception
{
final String savedImageFile = "d:\\my.jpg"; //拍摄所存储的文件
OpenCVFrameGrabber grabber = new OpenCVFrameGrabber(0);
grabber.start(); //开始获取摄像头数据
IplImage image =grabber.grab(); //将所获取摄像头数据放入IplImage
int width = image.width();
int height = image.height();
final BufferedImage bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D bGraphics = bImage.createGraphics();
CanvasFrame canvas = new CanvasFrame("Camera",1);
canvas.setCanvasSize(width, height);
canvas.getCanvas().addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
try{
ImageIO.write(bImage, "jpg", new File(savedImageFile));//数据写入my.jpg
}
catch (IOException e1){
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
while(canvas.isVisible() && (image=grabber.grab()) != null){
canvas.showImage(image);
bGraphics.drawImage(image.getBufferedImage(),null,0,0);
}
cvReleaseImage(image);
grabber.stop();
canvas.dispose();
}
}