Class CameraDesktopService
java.lang.Object
com.serinity.accesscontrol.service.CameraDesktopService
CameraService handles webcam access and frame capture.
- Since:
- 2026-02-27 CameraDesktopService.java
- Version:
- 1.0
- Author:
- @ZouariOmar (zouariomar20@gmail.com)
-
Constructor Summary
ConstructorsConstructorDescriptionCameraDesktopService(int cameraIndex) Creates a camera service bound to the given camera index. -
Method Summary
Modifier and TypeMethodDescriptionorg.opencv.core.MatCaptures a single frame from the camera.voidclose()Releases the camera resources.booleanisOpen()Indicates whether the camera is open and usable.startCapture(Consumer<org.opencv.core.Mat> frameConsumer, AtomicBoolean running) Starts a background thread that continuously captures frames from the camera and passes each frame to the provided consumer.
-
Constructor Details
-
CameraDesktopService
public CameraDesktopService(int cameraIndex) Creates a camera service bound to the given camera index.- Parameters:
cameraIndex- zero-based camera index
-
-
Method Details
-
isOpen
public boolean isOpen()Indicates whether the camera is open and usable.- Returns:
truewhen capture is available
-
startCapture
Starts a background thread that continuously captures frames from the camera and passes each frame to the provided consumer.The loop runs as long as
runningistrueand the camera is open. Setrunningtofalseto stop capture gracefully.- Parameters:
frameConsumer- callback invoked with each capturedMatframerunning- atomic flag; set tofalseto stop the loop- Returns:
- capture thread that was started
-
captureFrame
public org.opencv.core.Mat captureFrame()Captures a single frame from the camera.- Returns:
- OpenCV Mat containing the frame
-
close
public void close()Releases the camera resources.
-