Skip to content

rpicam-apps tflite #1529

Description

@jwinarske

With PR #1517 I am able to run rpicam-hello --mode 640:480:10:P --viewfinder-width 640 --viewfinder-height 480 --timeout 0 --post-process-file /usr/share/rpi-camera-assets/object_classify_tf.json with this meta-tensorflow patch:

diff --git a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
index 786507e..99a0d3b 100644
--- a/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
+++ b/recipes-framework/tensorflow/tensorflow-lite_2.19.0.bb
@@ -31,7 +31,7 @@ SRC_URI += "https://storage.googleapis.com/download.tensorflow.org/models/tflite
 SRC_URI[model-mobv1.md5sum] = "38ac0c626947875bd311ef96c8baab62"
 SRC_URI[model-mobv1.sha256sum] = "2f8054076cf655e1a73778a49bd8fd0306d32b290b7e576dda9574f00f186c0f"
 
-RDEPENDS:${PN} += " \
+RDEPENDS:${PN}-python += " \
     python3 \
     python3-core \
     python3-numpy \
@@ -90,8 +90,26 @@ do_compile () {
 
 do_install() {
     install -d ${D}${libdir}
+    # Create versioned library and unversioned symlink
     install -m 644 ${S}/bazel-bin/tensorflow/lite/libtensorflowlite.so \
-        ${D}${libdir}
+        ${D}${libdir}/libtensorflowlite.so.${PV}
+    ln -sf libtensorflowlite.so.${PV} ${D}${libdir}/libtensorflowlite.so
+
+    # Install missing pkg-config file
+    install -d ${D}${libdir}/pkgconfig
+    cat > ${D}${libdir}/pkgconfig/tensorflow-lite.pc << 'EOF'
+prefix=${prefix}
+exec_prefix=${exec_prefix}
+libdir=${libdir}
+includedir=${includedir}
+
+Name: TensorFlow Lite
+Description: TensorFlow Lite inference library
+Version: ${PV}
+Requires:
+Libs: -L${libdir} -ltensorflowlite
+Cflags: -I${includedir}
+EOF
 
     install -d ${D}${sbindir}
     install -m 755 ${S}/bazel-bin/tensorflow/lite/tools/benchmark/benchmark_model \
@@ -148,7 +166,12 @@ do_install() {
 
 }
 
-FILES:${PN} += "${libdir} ${sbindir} ${datadir}/*"
+PACKAGES =+ "${PN}-python"
+
+FILES:${PN}-python += " ${libdir}/python*"
+FILES:${PN} += "${sbindir} ${datadir}/* ${libdir}/libtensorflowlite.so.*"
+FILES:${PN}-dev = "${includedir} ${libdir}/libtensorflowlite.so ${libdir}/pkgconfig/tensorflow-lite.pc"
+
 INSANE_SKIP:${PN} += "dev-so \
                       already-stripped \
                      "

requires local.conf addition:

PACKAGECONFIG:append:pn-rpicam-apps = " tflite"

Also JSON paths require fixing up to match where meta-tensorflow tensorflow-lite recipe installs things:

"model_file" : "/home/pi/models/mobilenet_v1_1.0_224_quant.tflite",
"labels_file" : "/home/pi/models/labels.txt",

to

"model_file" : "/usr/share/label_image/mobilenet_v1_1.0_224_quant.tflite",
"labels_file" : "/usr/share/label_image/labels_mobilenet_quant_v1_224.txt",

Log output

root@raspberrypi5:/home/weston# rpicam-hello --mode 640:480:10:P --viewfinder-width 640 --viewfinder-height 480 --timeout 0 --post-process-file /usr/share/rpi-camera-assets/object_classify_tf.json
[0:16:05.980119241] [5218]  INFO Camera camera_manager.cpp:330 libcamera v0.5.2+99-bfd68f78-dirty (2025-10-18T16:14:03UTC)
[0:16:05.994172741] [5219]  INFO RPI pisp.cpp:720 libpisp version v1.3.0 9ba67e6680f0 09-10-2025 (11:51:16)
[0:16:05.997467587] [5219]  INFO IPAProxy ipa_proxy.cpp:180 Using tuning file /usr/share/libcamera/ipa/rpi/pisp/imx219.json
[0:16:06.007397497] [5219]  INFO Camera camera_manager.cpp:220 Adding camera '/base/axi/pcie@1000120000/rp1/i2c@80000/imx219@10' for pipeline handler rpi/pisp
[0:16:06.007445108] [5219]  INFO RPI pisp.cpp:1179 Registered camera /base/axi/pcie@1000120000/rp1/i2c@80000/imx219@10 to CFE device /dev/media0 and ISP device /dev/media2 using PiSP variant BCM2712_C0
Made DRM preview window
Reading post processing stage "object_classify_tf"
TfStage: Loaded model /usr/share/label_image/mobilenet_v1_1.0_224_quant.tflite
Reading post processing stage "annotate_cv"
Mode selection for 640:480:12:P
    SRGGB10_CSI2P,640x480/0 - Score: 1000
    SRGGB10_CSI2P,1640x1232/0 - Score: 1444.49
    SRGGB10_CSI2P,1920x1080/0 - Score: 1636.67
    SRGGB10_CSI2P,3280x2464/0 - Score: 2162.49
    SRGGB8,640x480/0 - Score: 2000
    SRGGB8,1640x1232/0 - Score: 2444.49
    SRGGB8,1920x1080/0 - Score: 2636.67
    SRGGB8,3280x2464/0 - Score: 3162.49
Stream configuration adjusted
[0:16:06.126494466] [5218]  INFO Camera camera.cpp:1215 configuring streams: (0) 640x480-YUV420/sYCC (1) 640x480-BGGR_PISP_COMP1/RAW
[0:16:06.126627689] [5219]  INFO RPI pisp.cpp:1483 Sensor: /base/axi/pcie@1000120000/rp1/i2c@80000/imx219@10 - Selected sensor format: 640x480-SBGGR10_1X10/RAW - Selected CFE format: 640x480-PC1B/RAW
TfStage: no low resolution stream
TfStage: Main stream is 640x480

Looking into:
TfStage: no low resolution stream
likely it wants 320x240

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions