Camera Stream on DJI Matrice 300 RTK
Hi all, I'm a developer (actually, I'm a researcher), but following the tutorials, APIs, and guides, it is not clear to me how to show, on my custom Android Java app, what my current H20 camera is currently capturing. I was able with MSDK 4.x, but with 5.x I have issues...
I don't need the code, I will do it by myself (in case I will ask you), but I need the logical steps.
I would assume something like:
- Add an object of something on your layout.xml (I don't know exactly which component)
- Add some listeners...
- Do this
- Do that
Thanks.
Agent comment from SHENRONG.LE in Zendesk ticket #127535:
Dear developers,
Hello, thank you for contacting DJI Innovation.
Do you use PSDK for camera development?
I hope our solution can help you, thank you for your email, wish you a happy life!
Best Regards,
Dji innovation SDK technical support
°°°
No, I need to use msdk 5.12. Simple Java Android app. I use H20 camera on my Matrice 300.
Agent comment from SHENRONG.LE in Zendesk ticket #127535:
Dear developers,
Hello, thank you for contacting DJI Innovation.
Sorry, there is no complete java version of the sample code, only using kontlin syntax written sample, about the process, you need to see how the sample code control PTZ camera 5.12: https://github.com/dji-sdk/Mobile-SDK-Android-V5
https://sdk-forum.dji.net/hc/zh-cn/articles/9125759407769-%E7%AC%AC%E5%8D%81%E4%BA%8C%E7%AB%A0-%E4%BA%91%E5%8F%B0
Thank you for your understanding and support, I wish you a happy life!
Best Regards,
Dji innovation SDK technical support
°°°
I don't mind if kotlin or java, I just need logical steps to do. Additionally, the second link you provided is about the gimbal, so I don't need it.
I try to explain my issue again. On my Matrice, I have my H20 camera. Then, on my Android app I need to show/stream what the zoom camera is currently looking at. So something like video streaming. I don't need to save the stream, just to visualize it.
Agent comment from SHENRONG.LE in Zendesk ticket #127535:
Dear developers,
Hello, thank you for contacting DJI Innovation.
Have you tried running the MSDK sample code? Do you mean to develop a set of code to display video streaming images of drones by yourself, similar to the sample code provided by the official?
Thank you for your understanding and support, I wish you a happy life!
Best Regards,
Dji innovation SDK technical support
°°°
I'm not able to run the MSDK sample code due to many errors. I use Kubuntu 24.10. However, I was able to create a small new project setting the simulator, wayline missions, and so on. My next step would be to stream the video captured by the camera. If you had the .apk version of MSDK sample code, I would be glad to install it.
Agent comment from SHENRONG.LE in Zendesk ticket #127535:
Dear developers,
Hello, thank you for contacting DJI Innovation.
You can run the instructional video by following the sample code provided on the official website: https://developer.dji.com/doc/mobile-sdk-tutorial/cn/quick-start/run-sample.html
Thank you for your understanding and support, I wish you a happy life!
Best Regards,
Dji innovation SDK technical support
°°°
This is not an answer though. I asked a bit of details about the sample code, not how to compile it. I don't need to compile the big sample, I just need to learn how to stream the video on my application. That's it.
Agent comment from SHENRONG.LE in Zendesk ticket #127535:
Dear developers,
Hello, thank you for contacting DJI Innovation.
Such as
- Add a TextureView object to your layout.xml file
- Initialize the UI component in your Activity or Fragment
- Register and connect the aircraft
- Set up video stream monitor
- Initialize all components in the onCreate method
- Handle life cycle events With the above steps, you should be able to display live video streams from your H20 camera on a custom Android app.
For video streaming details, you can look at MSDK related technical documents: 第五章:视频流解码
I hope our solution can help you, thank you for your email, wish you a happy life!
Best Regards,
Dji innovation SDK technical support
°°°
Agent comment from SHENRONG.LE in Zendesk ticket #127535:
Dear developers,
Hello, thank you for contacting DJI Innovation.
At present, this channel only provides technical support for MSDK. If you need to implement video streaming related, you need to build your own framework to find solutions. It is recommended that you use the sample code provided by the official and the appropriate drone, and the sample code runs to see the details.
I hope our solution can help you, thank you for your email, wish you a happy life!
Best Regards,
Dji innovation SDK technical support
°°°
Agent comment from SHENRONG.LE in Zendesk ticket #127535:
Dear developers,
Hello, thank you for contacting DJI Innovation.
In addition, there is no MSDK sample code framework written entirely in java, if you need to implement video streaming details in a similar scheme, you will need to use kontlin.
I hope our solution can help you, thank you for your email, wish you a happy life!
Best Regards,
Dji innovation SDK technical support
°°°
Hi, I managed to do that:
In my layout, I put this
<SurfaceView
android:id="@+id/sv_camera_stream"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="fill" />
Then, on my .java
svCameraStream = findViewById(R.id.sv_camera_stream);
initRGCamera();
Where:
private void initRGCamera() {
CameraStreamManager.getInstance().addAvailableCameraUpdatedListener(new ICameraStreamManager.AvailableCameraUpdatedListener() {
@Override
public void onAvailableCameraUpdated(@NonNull List<ComponentIndexType> availableCameraList) {
Log.i(TAG, "onAvailableCameraUpdated: " + availableCameraList.size());
if (!availableCameraList.isEmpty()) {
MediaDataCenter.getInstance().getCameraStreamManager().putCameraStreamSurface(
ComponentIndexType.LEFT_OR_MAIN,
svCameraStream.getHolder().getSurface(),
svCameraStream.getWidth(),
svCameraStream.getHeight(),
ICameraStreamManager.ScaleType.CENTER_CROP
);
KeyManager.getInstance().setValue(KeyTools.createKey(CameraKey.KeyCameraVideoStreamSource), CameraVideoStreamSourceType.ZOOM_CAMERA, new CommonCallbacks.CompletionCallback() {
@Override
public void onSuccess() {
Log.i(TAG, "onSuccess ZOOM_CAMERA");
}
@Override
public void onFailure(@NonNull IDJIError idjiError) {
Log.i(TAG, "onFailure ZOOM_CAMERA: " + idjiError);
}
});
}
}
});
svCameraStream.setVisibility(View.VISIBLE);
}