Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meta-iotqa/conf/test/refkit-image-computervision.manifest
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Tests for computervision profile
oeqa.runtime.multimedia.realsense.realsense_headless
oeqa.runtime.multimedia.opencl.opencl_viennacl_1
oeqa.runtime.multimedia.opencv.opencv_dnn_1
11 changes: 11 additions & 0 deletions meta-iotqa/lib/oeqa/runtime/multimedia/opencv/opencv_dnn_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from oeqa.oetest import oeRuntimeTest

class OpenCVDNN1Test(oeRuntimeTest):
def test_opencv_dnn_1(self):
# Classify an image using opencv-dnn
(status, output) = self.target.run('dnn-test.py /usr/share/Caffe/data/deploy.prototxt /usr/share/Caffe/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel /usr/share/Caffe/data/dog.jpg')
# The dog must be identified as Saluki, gazelle hound. It's
# index 176.
self.assertEqual(status, 0, msg="Error messages: %s" % output)
lines = output.split("\n")
self.assertEqual(lines[-1], "176", msg="Misclassified image(%s): %s " % (lines[-1], output))
2 changes: 1 addition & 1 deletion meta-openembedded
Submodule meta-openembedded updated from b06378 to d2da8b
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Copyright (C) 2017 Ismo Puustinen <ismo.puustinen@intel.com>
# Released under the MIT license (see COPYING.MIT for the terms)

DESCRIPTION = "Download the BVLC reference network as test data."
HOMEPAGE = "https://github.com/BVLC/caffe/tree/master/models/bvlc_reference_caffenet"
LICENSE = "BVLC-model-license & CC-BY-2.5 & BSD-3-Clause"
SECTION = "tests"
DEPENDS = ""

# Image by Lilly M #
# (https://en.wikipedia.org/wiki/Saluki#/media/File:Chart_perski_0002.jpg)
# using CC BY 2.5 license (https://creativecommons.org/licenses/by/2.5/)
LIC_FILES_CHKSUM = " \
file://${COMMON_LICENSE_DIR}/CC-BY-SA-3.0;md5=3248afbd148270ac7337a6f3e2558be5 \
file://${WORKDIR}/LICENSE;md5=650b869bd8ff2aed59c62bad2a22a821 \
"

SRC_URI = " \
http://dl.caffe.berkeleyvision.org/caffe_ilsvrc12.tar.gz;name=ilsvrc12 \
http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel;name=caffenet \
https://raw.githubusercontent.com/BVLC/caffe/f16b5f2eb96cbb97d9a4b2b7312a23cb16f43dac/models/bvlc_reference_caffenet/deploy.prototxt;name=deploy \
https://upload.wikimedia.org/wikipedia/commons/2/27/Chart_perski_0002.jpg;downloadfilename=dog.jpg;name=dog \
https://raw.githubusercontent.com/opencv/opencv_contrib/009d2efb75fbb0eded127864cb1ca932d58d1738/LICENSE;name=bsd3 \
file://dnn-test.py \
file://change_input_format.patch \
"

SRC_URI[ilsvrc12.md5sum] = "f963098ea0e785a968ca1eb634003a90"
SRC_URI[ilsvrc12.sha256sum] = "e35c0c1994a21f7d8ed49d01881ce17ab766743d3b0372cdc0183ff4d0dfc491"

SRC_URI[caffenet.md5sum] = "af678f0bd3cdd2437e35679d88665170"
SRC_URI[caffenet.sha256sum] = "472d4a06035497b180636d8a82667129960371375bd10fcb6df5c6c7631f25e0"

SRC_URI[deploy.md5sum] = "955051d11e44bd29dd87a25dd766ec23"
SRC_URI[deploy.sha256sum] = "922248a4d2f6aac1cc8e7e5dbd996cc2ecd3356480d67c198f6cf96b12311a04"

SRC_URI[dog.md5sum] = "76efa2a64d2c78078166f8f4ff375682"
SRC_URI[dog.sha256sum] = "f163822499bdd03a3bf4d3cb437d52ab5082d51edbcb7c98f1c42101d6358c70"

SRC_URI[bsd3.md5sum] = "650b869bd8ff2aed59c62bad2a22a821"
SRC_URI[bsd3.sha256sum] = "7c34d28e784b202aa4998f477fd0aa9773146952d7f6fa5971369fcdda59cf48"

do_patch_prepend() {
bb.utils.movefile(os.path.join(d.getVar("WORKDIR"), "deploy.prototxt"), d.getVar("S"))
}

do_install() {
install -d ${D}${datadir}/Caffe/models/bvlc_reference_caffenet/
install -d ${D}${datadir}/Caffe/data/ilsvrc12
install -d ${D}${bindir}

install ${WORKDIR}/synset_words.txt ${D}${datadir}/Caffe/data/ilsvrc12
install ${WORKDIR}/bvlc_reference_caffenet.caffemodel ${D}${datadir}/Caffe/models/bvlc_reference_caffenet/
install ${S}/deploy.prototxt ${D}${datadir}/Caffe/data/
install ${WORKDIR}/dog.jpg ${D}${datadir}/Caffe/data/
install -m 755 ${WORKDIR}/dnn-test.py ${D}${bindir}
}

FILES_${PN} += "${datadir}/Caffe/*"

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/deploy.prototxt b/deploy.prototxt
index 907116e..a3de789 100644
--- a/deploy.prototxt
+++ b/deploy.prototxt
@@ -1,10 +1,11 @@
name: "CaffeNet"
-layer {
- name: "data"
- type: "Input"
- top: "data"
- input_param { shape: { dim: 10 dim: 3 dim: 227 dim: 227 } }
-}
+
+input: "data"
+input_dim: 10
+input_dim: 3
+input_dim: 224
+input_dim: 224
+
layer {
name: "conv1"
type: "Convolution"

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python3

# Classify an image using a suitable model. The image conversion magic
# is from
# https://github.com/opencv/opencv_contrib/blob/master/modules/dnn/samples/googlenet_python.py
# (3-clause BSD license).

import numpy as np
import cv2
import sys

if len(sys.argv) != 4:
print("Usage: dnn.py <prototxt> <caffemodel> <image>")
sys.exit(1)

cv2.ocl.setUseOpenCL(False)

# read the image
test_img = cv2.imread(sys.argv[3])

# resize
resized = cv2.resize(test_img, (224,224))
converted = np.moveaxis(resized, 2, 0)
data = np.reshape(converted.astype(np.float32), (-1, 3, 224, 224))

# initialize network
net = cv2.dnn.readNetFromCaffe(sys.argv[1], sys.argv[2])
net.setBlob(".data", data)

# run the network
net.forward()

# print the class
print(str(net.getBlob("prob").argmax()))
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ RDEPENDS_${PN} = " \
python3-opencv \
librealsense-examples \
viennacl-examples \
caffe-bvlc-reference \
"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Add missing runtime dependency to udev rule files.
RDEPENDS_${PN}-udevrules_append_class-target = " lvm2"
10 changes: 8 additions & 2 deletions meta-refkit-core/conf/distro/include/refkit-config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,14 @@ PACKAGECONFIG_append_pn-ovmf_df-refkit-config = " secureboot"
# only build minimal gstreamer1.0-plugins-bad
PACKAGECONFIG_pn-gstreamer1.0-plugins-bad_df-refkit-config ?= ""

# Enable OpenCL.
PACKAGECONFIG_append_pn-opencv_df-refkit-config = " opencl"
# Enable OpenCL and DNN modules.
PACKAGECONFIG_append_pn-opencv_df-refkit-config = " opencl dnn"

#########################################################################
# Changes that normally are better suited for a .bbappend have
# to be done here if the corresponding .bb file is not guaranteed
# to be present (i.e. outside of OE-core).
#########################################################################

# Use nftables instead of iptables.
PACKAGECONFIG_remove_pn-connman_df-refkit-config = "iptables"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ bubblewrap@flatpak-layer
busybox@core
bzip2@core
ca-certificates@core
caffe-bvlc-reference@refkit-computervision
cairo@core
cantarell-fonts@core
catkin-runtime@ros-layer
Expand Down