milas / rock5-toolchain

Dockerized build environment for Rock 5B vendor kernel & related (e.g. U-Boot) components
23 stars 4 forks source link

RKMPP + RKNN? #1

Open irjkf129 opened 11 months ago

irjkf129 commented 11 months ago

Good afternoon I'm writing an application for real-time processing of car numbers, and for this I want to use rockchip-toolkit and rkmpp at the same time. But I don’t fully understand, is it possible to somehow take your two assemblies and combine them in order to use both rknn and rkmpp?

milas commented 11 months ago

You understand correct - there is no convenient way to use them together 😛

I would recommend doing a multistage build and then using the rkmpp Debian image as a base image for your app, which will have Gstreamer and rkmpp libraries in-place:

FROM <base image> AS build

RUN ... compile your app ...

FROM milas/rkmpp-debian:bullseye

COPY --link --from=build /out/your-app /
CMD ["/your-app"]

For rknn, if you only need the C library, I would add rockchip/rknpu2 as a Git submodule and use rknn_api.h & librknnrt.so from it.

You can also do it all from it in Docker:

# syntax=docker/dockerfile:1
FROM scratch AS git-rknpu2

ADD https://github.com/rockchip-linux/rknpu2.git /

milas/rkmpp-debian:bullseye

COPY --link --from=git-rknpu2 /runtime/RK3588/Linux/librknn_api/aarch64/*.so /usr/local/lib/
RUN ldconfig

# header file for compilation
COPY --link --from=git-rknpu2 /runtime/RK3588/Linux/librknn_api/include/*.h /usr/local/include/

I hope that's helpful 😅

If you want to see a more complete example, take a look at https://github.com/milas/rkoxide/blob/main/crates/rknn-demo/Dockerfile

irjkf129 commented 11 months ago

Hello! I tried building on milas/rkmpp-debian:bullseye and installing python3.8-dev on top of it, and it seemed to work. I haven't tested with GStreamer yet, but rknn model works! Perhaps there will be some problems. Is it worth keeping up to date on progress, will it be useful to you?