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;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?KeyManager.getInstance().setValue(KeyTools.createKey(CameraKey.KeyCameraVideoStreamSource), CameraVideoStreamSourceType.ZOOM_CAMERA, new CommonCallbacks.CompletionCallback() {...}
-
If the minimum distance provided by Pilot 2 is 1 meter, then there are currently no other methods to adjust the perception distance to a smaller value. Regarding the aircraft speed, are you referring to adjusting the sensitivity of the RC PRO joystick? You may want to take a look at this article: https://sdk-forum.dji.net/hc/en-us/articles/34181248765081 -
Thanks a lot, DJI Developer Support!
I tried to configure the aircraft speed programmatically, but I haven't been successful yet. Could you provide an example of how to set this by code? Here’s a sample snippet that I'm trying to use:
KeyManager.getInstance().listen(KeyTools.createKey(FlightControllerKey.KeyHorizMaxSpeedInNormal), this, (oldValue, newValue) -> {
appToast.notifyFront("alert", "DSS equals " + newValue + " But before was " + oldValue);
});// Set drone speed sensitivity in Normal Mode
// KeyManager.getInstance().setValue(KeyTools.createKey(FlightControllerKey.KeyFlightMode), FlightMode.GPS_SPORT, new CommonCallbacks.CompletionCallback() {
KeyManager.getInstance().setValue(KeyTools.createKey(FlightControllerKey.KeyHorizMaxSpeedInNormal), Double.valueOf("1"), new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
log.info("Drone is slow!");
}
@Override
public void onFailure(@NonNull IDJIError error) {
log.error("Error setting drone in speed mode: " + error.description() + ", CODE: " + error.errorCode());
}
});It would be ideal to control the aircraft speed directly by code for safety reasons. However, I found that these parameters can also be adjusted directly within the app in the settings screen, which might be helpful for others looking for a quick solution.
Thanks again for your guidance!
-
Your usage of ‘key’ was mostly correct. The FlightControllerKey.KeyFlightMode cannot be set; it can only be read. If you need to change the control gear of the remote controller, you will need to do so using the physical switch on the remote, as it cannot be done through code. In Sport mode, the maximum horizontal speed should be set using KeyMaxHorizSpeedIn**Sport.**
请先登录再写评论。
评论
10 条评论