[JAVA] Desktop: OpenCV take a clear picture

Goal
Last time OpenCV taking a dark picture, this time modify some code and get a clear picture.

OpenCV_webcam2.java



import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.videoio.VideoCapture;

public class OpenCV_webcam2 {

	static {
		System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
	}
	
	public static void main(String[] args) {
		VideoCapture camera = new VideoCapture();
		camera.open(0);
		
		if(!camera.isOpened()) {
			System.out.println("Error");
		}else {
			Mat frame = new Mat();
			try {
				System.out.println("Use webcam beat lighting Ryo version");
				camera.read(frame);
				Thread.sleep(500);
				camera.read(frame);
				Thread.sleep(500);
				camera.read(frame);
				Thread.sleep(500);
				
				Imgcodecs.imwrite("D:\\projects\\Java\\OpenCV_Samples\\resource\\imgs\\frame_clear.jpg ",frame);
				System.out.println("Completion of clapping");
				
			}catch(Exception e) {
				e.printStackTrace();
			}
		}
		camera.release();
	}
}

Result
![frame_clear.jpg](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/276243/256f14df-351c-8966-49db-996e5e43e67a.jpeg)

Recommended Posts

Desktop: OpenCV take a clear picture
Desktop: OpenCV take a picture
Desktop: OpenCV manual a take picture
Desktop: OpenCV merge Picture
Desktop: OpenCV Threshold
Desktop: OpenCV Dilate
Desktop: OpenCV Expand
Desktop: OpenCV Affine
Desktop: OpenCV Emboss
Desktop: OpenCV CLAHE
Desktop: OpenCV HDR
Desktop: OpenCV Polylines
Desktop: OpenCV Denoise
Desktop: OpenCV Sharpness
Desktop: OpenCV Concat
Desktop: OpenCV OpenCV_SalonUseBlurAddWeighted
Desktop: OpenCV Mosaic
Desktop: OpenCV Erode
Desktop: OpenCV Denoise
Desktop: OpenCV Rectangle
Desktop: OpenCV Watershed
Desktop: OpenCV Text
Desktop: OpenCV NormalizeBlur
Desktop: OpenCV StereoSGBM
Desktop: OpenCV Spot
Desktop: OpenCV Canny
Desktop: OpenCV Denoise3
Desktop: OpenCV Histogram
Desktop: OpenCV Dft
Desktop: OpenCV Decolor
Desktop: OpenCV FaceDetector
Desktop: OpenCV Denoise2
Desktop: OpenCV StereoBM
Desktop: OpenCV Kirsch Filter
Desktop: OpenCV Laplacian Filter 2
Desktop: OpenCV Add WaterMark
Desktop: OpenCV Fill ConvexPoly
Desktop: OpenCV Grab Cut
Desktop: OpenCV Sharpness Gui
Desktop: OpenCV Freichennel Filter
Desktop: OpenCV Draw Circle
Desktop: OpenCV Mean Filter
Desktop: OpenCV Sobel Filter2
Desktop: OpenCV OpticalFlow PyrLK
Desktop: OpenCV Virtual Piano
Desktop: OpenCV Scharr Filter
Desktop: Opencv webcam preview
Desktop: OpenCV Laplacian Filter
Desktop: OpenCV Median Blur
Desktop: OpenCV Add Broad
Desktop: OpenCV Robinson Filter
Desktop: OpenCV record video
Desktop: OpenCV Texture Flatting
Desktop: OpenCV Flood Fill
Desktop: OpenCV color space
Desktop: OpenCV SqrBox Filter
Desktop: OpenCV resize image
Desktop: OpenCV Pencil Sketch
Desktop: OpenCV Color Map
Desktop: OpenCV Draw Point
Desktop: OpenCV Sobel Filter