Improvement 21/01/2025
This commit is contained in:
@@ -10,7 +10,7 @@ public enum ObsbotMeet2 {
|
||||
Mode4(0.2, 640, 360, "16:9"),
|
||||
Mode5(0.3, 640, 480, "4:3"),
|
||||
ModeBest(8.3, 3840, 2160, "16:9"),
|
||||
ModeLive(0.3, 640, 480, "4:3");
|
||||
ModeLive(0.3, 640, 360, "16:9");
|
||||
|
||||
private final double Megapixel;
|
||||
private final int width;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package id.co.gtc.erhacam;
|
||||
|
||||
import Camera.ArducamIMX477Preset;
|
||||
import Camera.CameraProperty;
|
||||
import Camera.LiveCamEvent;
|
||||
import Camera.ObsbotMeet2Preset;
|
||||
import Config.CameraConfigEnum;
|
||||
import Config.SomeCodes;
|
||||
import com.google.zxing.BinaryBitmap;
|
||||
@@ -44,8 +44,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static Config.SomeCodes.*;
|
||||
import static id.co.gtc.erhacam.Detectors.faceDetector;
|
||||
import static id.co.gtc.erhacam.Detectors.eyeDetector;
|
||||
import static id.co.gtc.erhacam.Detectors.*;
|
||||
import static org.bytedeco.opencv.global.opencv_core.CV_8UC3;
|
||||
import static org.bytedeco.opencv.global.opencv_core.mean;
|
||||
import static org.bytedeco.opencv.global.opencv_imgcodecs.imwrite;
|
||||
@@ -103,7 +102,7 @@ public class Cameradetail {
|
||||
private final UMat BestMat = new UMat();
|
||||
private final UMat LiveMat = new UMat();
|
||||
private final UMat ReducedMat = new UMat();
|
||||
private Size LiveSize = new Size(640, 480);
|
||||
private Size LiveSize = new Size(640, 360);
|
||||
private Size ReducedSize = new Size(1280, 720);
|
||||
private Size BestSize = new Size(1920, 1080);
|
||||
|
||||
@@ -143,12 +142,12 @@ public class Cameradetail {
|
||||
streamanchor.widthProperty().addListener(obs -> resize_streamanchor());
|
||||
|
||||
Platform.runLater(()->{
|
||||
setSliderValue(brightnessSlider, ArducamIMX477Preset.Brightness, config.getBrightness(cameraConfigEnum));
|
||||
setSliderValue(contrastSlider, ArducamIMX477Preset.Contrast, config.getContrast(cameraConfigEnum));
|
||||
setSliderValue(saturationSlider, ArducamIMX477Preset.Saturation, config.getSaturation(cameraConfigEnum));
|
||||
setSliderValue(hueSlider, ArducamIMX477Preset.Hue, config.getHue(cameraConfigEnum));
|
||||
setSliderValue(gainSlider, ArducamIMX477Preset.Gain, config.getGain(cameraConfigEnum));
|
||||
setSliderValue(exposureSlider, ArducamIMX477Preset.ExposureTime, config.getExposure(cameraConfigEnum));
|
||||
setSliderValue(brightnessSlider, ObsbotMeet2Preset.Brightness, config.getBrightness(cameraConfigEnum));
|
||||
setSliderValue(contrastSlider, ObsbotMeet2Preset.Contrast, config.getContrast(cameraConfigEnum));
|
||||
setSliderValue(saturationSlider, ObsbotMeet2Preset.Saturation, config.getSaturation(cameraConfigEnum));
|
||||
setSliderValue(hueSlider, ObsbotMeet2Preset.Hue, config.getHue(cameraConfigEnum));
|
||||
setSliderValue(gainSlider, ObsbotMeet2Preset.Gain, config.getGain(cameraConfigEnum));
|
||||
setSliderValue(exposureSlider, ObsbotMeet2Preset.ExposureTime, config.getExposure(cameraConfigEnum));
|
||||
|
||||
});
|
||||
|
||||
@@ -189,12 +188,12 @@ public class Cameradetail {
|
||||
|
||||
@FXML
|
||||
public void resetClick(){
|
||||
brightnessSlider.adjustValue(ArducamIMX477Preset.Brightness.Default);
|
||||
contrastSlider.adjustValue(ArducamIMX477Preset.Contrast.Default);
|
||||
saturationSlider.adjustValue(ArducamIMX477Preset.Saturation.Default);
|
||||
hueSlider.adjustValue(ArducamIMX477Preset.Hue.Default);
|
||||
gainSlider.adjustValue(ArducamIMX477Preset.Gain.Default);
|
||||
exposureSlider.adjustValue(ArducamIMX477Preset.ExposureTime.Default);
|
||||
brightnessSlider.adjustValue(ObsbotMeet2Preset.Brightness.Default);
|
||||
contrastSlider.adjustValue(ObsbotMeet2Preset.Contrast.Default);
|
||||
saturationSlider.adjustValue(ObsbotMeet2Preset.Saturation.Default);
|
||||
hueSlider.adjustValue(ObsbotMeet2Preset.Hue.Default);
|
||||
gainSlider.adjustValue(ObsbotMeet2Preset.Gain.Default);
|
||||
exposureSlider.adjustValue(ObsbotMeet2Preset.ExposureTime.Default);
|
||||
|
||||
}
|
||||
|
||||
@@ -355,7 +354,7 @@ public class Cameradetail {
|
||||
*/
|
||||
public void setAutoExposure(boolean ON){
|
||||
if (mGrabber!=null){
|
||||
mGrabber.setOption(Videoio.CAP_PROP_AUTO_EXPOSURE, ON?ArducamIMX477Preset.AutoExposure.On:ArducamIMX477Preset.AutoExposure.Off);
|
||||
mGrabber.setOption(Videoio.CAP_PROP_AUTO_EXPOSURE, ON?ObsbotMeet2Preset.AutoExposure.On:ObsbotMeet2Preset.AutoExposure.Off);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +364,7 @@ public class Cameradetail {
|
||||
*/
|
||||
public boolean getAutoExposure(){
|
||||
if (mGrabber!=null){
|
||||
return mGrabber.getOption(Videoio.CAP_PROP_AUTO_EXPOSURE)==ArducamIMX477Preset.AutoExposure.On;
|
||||
return mGrabber.getOption(Videoio.CAP_PROP_AUTO_EXPOSURE)==ObsbotMeet2Preset.AutoExposure.On;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -397,7 +396,7 @@ public class Cameradetail {
|
||||
*/
|
||||
public void setAutoFocus(boolean ON){
|
||||
if (mGrabber!=null){
|
||||
mGrabber.setOption(Videoio.CAP_PROP_AUTOFOCUS, ON?ArducamIMX477Preset.AutoFocus.On:ArducamIMX477Preset.AutoFocus.Off);
|
||||
mGrabber.setOption(Videoio.CAP_PROP_AUTOFOCUS, ON?ObsbotMeet2Preset.AutoFocus.On:ObsbotMeet2Preset.AutoFocus.Off);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,20 +406,20 @@ public class Cameradetail {
|
||||
*/
|
||||
public boolean getAutoFocus(){
|
||||
if (mGrabber!=null){
|
||||
return mGrabber.getOption(Videoio.CAP_PROP_AUTOFOCUS)==ArducamIMX477Preset.AutoFocus.On;
|
||||
return mGrabber.getOption(Videoio.CAP_PROP_AUTOFOCUS)==ObsbotMeet2Preset.AutoFocus.On;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setAutoWB(boolean ON){
|
||||
if (mGrabber!=null){
|
||||
mGrabber.setOption(Videoio.CAP_PROP_AUTO_WB, ON?ArducamIMX477Preset.AutoWhiteBalance.On:ArducamIMX477Preset.AutoWhiteBalance.Off);
|
||||
mGrabber.setOption(Videoio.CAP_PROP_AUTO_WB, ON?ObsbotMeet2Preset.AutoWhiteBalance.On:ObsbotMeet2Preset.AutoWhiteBalance.Off);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getAutoWB(){
|
||||
if (mGrabber!=null){
|
||||
return mGrabber.getOption(Videoio.CAP_PROP_AUTO_WB)==ArducamIMX477Preset.AutoWhiteBalance.On;
|
||||
return mGrabber.getOption(Videoio.CAP_PROP_AUTO_WB)==ObsbotMeet2Preset.AutoWhiteBalance.On;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -791,28 +790,9 @@ public class Cameradetail {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect Face from Mat
|
||||
* @param graymat Mat in Gray Scale
|
||||
* @return RectVector if face detected, otherwise false
|
||||
*/
|
||||
private RectVector DetectFace(UMat graymat){
|
||||
if (faceDetector!=null){
|
||||
RectVector face = new RectVector();
|
||||
faceDetector.detectMultiScale(graymat, face);
|
||||
return face;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private RectVector DetectEye(UMat graymat){
|
||||
if (eyeDetector!=null){
|
||||
RectVector eye = new RectVector();
|
||||
eyeDetector.detectMultiScale(graymat, eye);
|
||||
return eye;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private double getBrightnessFromGrayMat(Mat graymat){
|
||||
Scalar mean = mean(graymat);
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package id.co.gtc.erhacam;
|
||||
|
||||
import Config.SomeCodes;
|
||||
import org.bytedeco.opencv.opencv_core.RectVector;
|
||||
import org.bytedeco.opencv.opencv_core.Size;
|
||||
import org.bytedeco.opencv.opencv_core.UMat;
|
||||
import org.bytedeco.opencv.opencv_objdetect.CascadeClassifier;
|
||||
import org.bytedeco.opencv.opencv_objdetect.CvHaarClassifierCascade;
|
||||
import org.tinylog.Logger;
|
||||
|
||||
public class Detectors {
|
||||
public static CascadeClassifier faceDetector;
|
||||
public static CascadeClassifier eyeDetector;
|
||||
|
||||
public static void LoadFaceDetector(){
|
||||
String filename = SomeCodes.ExtractResource("/haarcascade_profileface.xml");
|
||||
if (filename!=null) {
|
||||
@@ -24,6 +27,27 @@ public class Detectors {
|
||||
} else Logger.error("Unable to extract face detector file");
|
||||
}
|
||||
|
||||
static double scaleFactor = 1.1;
|
||||
static int minNeighbors = 3;
|
||||
static int flags = 0;
|
||||
static Size minSize = new Size(30, 30);
|
||||
static Size maxSize = new Size(300, 300);
|
||||
|
||||
/**
|
||||
* Detect Face from Mat
|
||||
* @param graymat Mat in Gray Scale
|
||||
* @return RectVector if face detected, otherwise false
|
||||
*/
|
||||
public static RectVector DetectFace(UMat graymat){
|
||||
if (faceDetector!=null){
|
||||
RectVector face = new RectVector();
|
||||
//faceDetector.detectMultiScale(graymat, face);
|
||||
faceDetector.detectMultiScale(graymat, face, scaleFactor, minNeighbors,flags, minSize, maxSize);
|
||||
return face;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void LoadEyeDetector(){
|
||||
String filename = SomeCodes.ExtractResource("/haarcascade_eye_tree_eyeglasses.xml");
|
||||
if (filename!=null) {
|
||||
@@ -41,4 +65,13 @@ public class Detectors {
|
||||
} else Logger.error("Unable to extract eye detector file");
|
||||
}
|
||||
|
||||
public static RectVector DetectEye(UMat graymat){
|
||||
if (eyeDetector!=null){
|
||||
RectVector eye = new RectVector();
|
||||
eyeDetector.detectMultiScale(graymat, eye);
|
||||
return eye;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
package id.co.gtc.erhacam;
|
||||
|
||||
import org.bytedeco.opencv.opencv_core.Mat;
|
||||
|
||||
public interface MatType {
|
||||
void CopyFrom(Mat src);
|
||||
void CopyTo(Mat dest);
|
||||
}
|
||||
Reference in New Issue
Block a user