Commit 25042025
This commit is contained in:
@@ -690,11 +690,15 @@ public class Cameradetail {
|
||||
|
||||
|
||||
if (!BestMat.empty()){
|
||||
UMat cloned;
|
||||
synchronized (BestMat){
|
||||
cloned = BestMat.clone();
|
||||
}
|
||||
|
||||
|
||||
// save BestMat at quality 9 PNG
|
||||
String filename = GetFullQualityPhotoPath(directory, prefix);
|
||||
|
||||
if (opencv_imgcodecs.imwrite(filename, BestMat, parampng)){
|
||||
if (opencv_imgcodecs.imwrite(filename, cloned, parampng)){
|
||||
result.setFullres(filename);
|
||||
} else System.out.println("TakePhoto failed, Unable to Save FullQUality Photo for camera "+cameratitle.getText());
|
||||
|
||||
@@ -707,7 +711,7 @@ public class Cameradetail {
|
||||
|
||||
// save ReducedMat at 100% JPEG
|
||||
String reducedfilename = GetReducedPhotoPath(directory, prefix);
|
||||
opencv_imgproc.resize(BestMat, ReducedMat, ReducedSize);
|
||||
opencv_imgproc.resize(cloned, ReducedMat, ReducedSize);
|
||||
if (!opencv_imgcodecs.imwrite(reducedfilename, ReducedMat, paramjpeg)){
|
||||
System.out.println("TakePhoto failed, Unable to Save Reduced Photo for camera "+cameratitle.getText());
|
||||
} else result.setCompressedfile(reducedfilename);
|
||||
@@ -717,6 +721,7 @@ public class Cameradetail {
|
||||
result.setCompressedcrop(xy);
|
||||
result.setReducedROI(new Rect(ReducedMatROI.x(), ReducedMatROI.y(), ReducedMatROI.width(), ReducedMatROI.height()));
|
||||
}
|
||||
cloned.release();
|
||||
|
||||
} else raise_log("TakePhoto failed, Live View is Empty");
|
||||
} catch (InterruptedException e){
|
||||
@@ -735,8 +740,10 @@ public class Cameradetail {
|
||||
|
||||
|
||||
public String CropBestMat(String directory, String prefix, Rect ROI){
|
||||
UMat cloned = new UMat();
|
||||
BestMat.copyTo(cloned);
|
||||
UMat cloned;
|
||||
synchronized (BestMat){
|
||||
cloned = BestMat.clone();
|
||||
}
|
||||
if (!cloned.empty()) {
|
||||
if (ValidROI(ROI)){
|
||||
if (ROIInsideUMat(ROI, cloned)){
|
||||
@@ -751,6 +758,7 @@ public class Cameradetail {
|
||||
} else Logger.error("CropBestMat failed, ROI is outside BestMat");
|
||||
} else Logger.error("CropBestMat failed, ROI is invalid");
|
||||
} else Logger.error("CropBestMat failed, BestMat is empty");
|
||||
cloned.release();
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -881,6 +889,7 @@ public class Cameradetail {
|
||||
if (rect.haveEyes()){
|
||||
rect.EyesRectangle(LiveMat);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1004,11 +1013,14 @@ public class Cameradetail {
|
||||
}
|
||||
|
||||
Mat imgmat = new Mat();
|
||||
LiveMat.copyTo(imgmat); // copy back to CPU
|
||||
|
||||
LiveMat.copyTo(imgmat);
|
||||
// copy back to CPU
|
||||
|
||||
setCameraStream(MatToImage(imgmat));
|
||||
imgmat.release();
|
||||
} catch (Exception e) {
|
||||
System.out.println(Thread.currentThread().getName()+" interrupted");
|
||||
//System.out.println(Thread.currentThread().getName()+" interrupted");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1098,20 +1110,20 @@ public class Cameradetail {
|
||||
UMat flippedmat = new UMat();
|
||||
opencv_core.flip(originalmat, flippedmat, 0); // flip vertical
|
||||
flippedmat.copyTo(originalmat);
|
||||
flippedmat.close();
|
||||
flippedmat.release();
|
||||
}
|
||||
if (config.isFlipCamera()){
|
||||
// revisi 18/03/2025
|
||||
UMat flippedmat = new UMat();
|
||||
opencv_core.flip(originalmat, flippedmat, 1); // flip horizontal
|
||||
flippedmat.copyTo(originalmat);
|
||||
flippedmat.close();
|
||||
flippedmat.release();
|
||||
}
|
||||
|
||||
// rotate 90 degree counter clockwise karena kamera potrait
|
||||
opencv_core.rotate(originalmat, BestMat, opencv_core.ROTATE_90_COUNTERCLOCKWISE);
|
||||
|
||||
|
||||
originalmat.release();
|
||||
|
||||
if (!BestMat.empty()) {
|
||||
|
||||
@@ -1306,6 +1318,7 @@ public class Cameradetail {
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
mat.release();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user