Zoom Disabled When Switching to Different Camera Modes on M3E Drone for High-Quality Image Capture
Hello everyone,
I'm currently using the M3E drone and this code to capture an image for reading a data matrix. To achieve this, I need a high-quality image. I've noticed other camera modes like PHOTO_HIGH_RESOLUTION
and PHOTO_SUPER_RESOLUTION
, but I can't seem to zoom in, which prevents me from using these modes effectively.
Is there another mode within CameraMode
or any alternative approach that could help me obtain a better image? If there are better methods to achieve this, please feel free to ask any questions needed to help solve this issue. Additionally, if you have examples or suggestions, I would greatly appreciate them.
Here’s the code snippet:
public void takePhoto(BitmapAnalyseCallback callback) {
long startTime = System.currentTimeMillis();
KeyManager.getInstance().setValue(KeyTools.createKey(CameraKey.KeyCameraMode), CameraMode.PHOTO_NORMAL, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
KeyManager.getInstance().performAction(KeyTools.createKey(CameraKey.KeyStartShootPhoto), new CommonCallbacks.CompletionCallbackWithParam<EmptyMsg>() {
@Override
public void onSuccess(EmptyMsg emptyMsg) {
Log.i("success", "Photo taken successfully");
new Thread(() -> {
try {
Thread.sleep(3000);
manager.pullMediaFileListFromCamera(new PullMediaFileListParam.Builder().mediaFileIndex(-1).count(1).build(), new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
Log.i("success", "Successfully pulled files from the camera");
for (MediaFile mediaFile : MediaDataCenter.getInstance().getMediaManager().getMediaFileListData().getData()) {
getBitmapFromMediaFile(mediaFile, bitmap -> {
ImageDetector.readBarCode(bitmap, callback);
Log.e("END_SCAN", "Scan completed: " + (System.currentTimeMillis() - startTime));
List<MediaFile> mediaFiles = new ArrayList<>();
mediaFiles.add(mediaFile);
manager.deleteMediaFiles(mediaFiles, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
Log.e("success", "Successfully deleted files from the camera");
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
Log.e("fail", "Error deleting files from the camera: " + idjiError.errorCode());
}
});
});
}
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
Log.e("fail", "Error pulling files from the camera: " + idjiError.errorCode());
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
Log.e("fail", "Error taking the photo: " + idjiError.errorCode());
}
});
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
Log.e("fail", "Error switching to photo mode: " + idjiError.errorCode());
}
});
}
Thank you!
-
Yes, because it’s the only way to read with the sensor active. Is it possible to reduce the sensor distance to less than two meters? Could you please run a test by creating a data matrix label with a size of 1.6 cm and this value: 2100000000006005611727]01434978]100141622024]1201052025]3000037489000]920]01434978]1001416?
We are currently using the following code to capture the label value:
import com.google.mlkit.vision.barcode.BarcodeScanner;
import com.google.mlkit.vision.barcode.BarcodeScannerOptions;
import com.google.mlkit.vision.barcode.BarcodeScanning;
import com.google.mlkit.vision.barcode.common.Barcode;
import com.google.mlkit.vision.common.InputImage;
...
frame = droneFlight.getFpvWidgetBitmap();
if (frame == null) continue;
String barcodeString = ImageDetector.readBarCode(frame);
if (barcodeString == null || barcodeString.isEmpty()) continue;public static String readBarCode(Bitmap bitmap) {
final String[] textBarCode = {""};
final CountDownLatch latch = new CountDownLatch(NUMBER_OF_COUNTDOWN_TO_RELEASE_THREADS);
try{
BarcodeScannerOptions options = new BarcodeScannerOptions.Builder()
.setBarcodeFormats(
Barcode.FORMAT_QR_CODE, Barcode.FORMAT_DATA_MATRIX, Barcode.FORMAT_CODE_128)
.build();
InputImage image = InputImage.fromBitmap(bitmap, 0);
BarcodeScanner detector = BarcodeScanning.getClient(options);
detector.process(image)
.addOnSuccessListener(barcodes -> {
for (Barcode barcode : barcodes) {
String rawValue = barcode.getRawValue();
if (textBarCode[0].isEmpty()) textBarCode[0] = rawValue;
else textBarCode[0] += "=/sep/=" + rawValue;
}
latch.countDown();
}).addOnFailureListener(e -> latch.countDown());
latch.await(READ_BARCODE_WAIT_DURATION, TimeUnit.MILLISECONDS);
} catch (Exception e) {
e.printStackTrace();
}
return textBarCode[0].isEmpty() ? null : textBarCode[0];
}
We are specifically using this code to extract the barcode data from the frame. Could you test this with the given label and let us know the results? -
You can switch the current view to a zoomed view using CameraKey.KeyCameraVideoStreamSource, and then control the zoom ratio with CameraKey.KeyCameraZoomRatios to make the target clearer. Sorry,but the barcode monitoring you mentioned is beyond our work. If the image remains blurry after zooming, you might consider bringing the aircraft closer to the target or using algorithms to enhance image clarity. These solutions will need to be implemented and tested by you. Regarding the sensor distance, are you referring to the sensors that the drone uses to detect obstacles? -
Thank you for the reply. I will test adjusting the view with CameraKey.KeyCameraVideoStreamSource and controlling the zoom with CameraKey.KeyCameraZoomRatios to improve the clarity of the target. Regarding the barcode monitoring, I understand that it's beyond your scope.
As for the sensor distance, yes, I am referring to the sensors the drone uses to detect obstacles. My goal is to better understand the minimum and optimal distance at which the drone can accurately detect objects. Any additional information on this would be greatly appreciated.
-
The obstacle sensor range of the aircraft can be less than 2 meters. If you have used the Pilot 2, you can view the perception range in different directions on the perception menu. The minimum distance in the horizontal direction is 0.5 meters. You may refer to this article for the guidance:https://sdk-forum.dji.net/hc/en-us/articles/9882785690009-Chapter-16-Visual-obstacle-avoidance-system https://developer.dji.com/doc/mobile-sdk-tutorial/en/tutorials/perception.html -
From what I see, the minimum distance seems to be 1 meter. Is there a way to set it to a shorter range for the horizontal sensor?
Also, do you know if it's possible to configure the drone's movement speed or calibrate the joystick’s sensitivity for speed control?
And what about the CameraKey configurations? Currently, I'm using this method in theonCreate
of my activity. Would this be the change needed to improve the image quality?public void switchCameraTypeToZoomAndSetFocus() {
KeyManager.getInstance().setValue(KeyTools.createKey(CameraKey.KeyCameraVideoStreamSource), CameraVideoStreamSourceType.ZOOM_CAMERA, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
log.info("Drone is now in camera zoom mode. Setting drone zoom to the default value...");
KeyManager.getInstance().setValue(KeyTools.createKey(CameraKey.KeyCameraZoomRatios), 1.0, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
log.info("Set drone zoom to 1.0 successfully");
sleepThreadUntilCameraCallback();
setFocus();
}
@Override
public void onFailure(@NonNull IDJIError error) {
log.error("Error setting zoom in drone: " + error.description() + ", CODE: " + error.errorCode());
}
});
}
@Override
public void onFailure(@NonNull IDJIError error) {
log.error("Error setting drone in camera zoom mode: " + error.description() + ", CODE: " + error.errorCode());
}
});
}
Please sign in to leave a comment.
Comments
6 comments