Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 6edb571

Browse files
authored
Merge pull request #170 from mythi/ci
Combine multiple PRs in one
2 parents 73f4d55 + 912bd2f commit 6edb571

8 files changed

Lines changed: 652 additions & 15 deletions

File tree

doc/computervision.rst

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
Computer Vision Profile
2+
#######################
3+
4+
Introduction
5+
============
6+
7+
Computer vision is about processing and extracting data from still
8+
images or videos. A classical example is classifying image content by
9+
using a model trained with large amounts of pre-labeled image data. The
10+
use cases are somewhat overlapping with AI and graphics, so computer
11+
vision profile provides also some special support for them.
12+
13+
Target audience
14+
===============
15+
16+
Computer vision profile is meant for anybody who needs to capture still images
17+
or video, process it, and then analyze it in IoT domain. Some example use cases:
18+
19+
#. Security cameras
20+
#. Automated drones and other vehicles
21+
#. Robots
22+
#. Wearables (smart glasses)
23+
#. Industrial vision, quality assurance
24+
#. Home automation
25+
#. Gesture control
26+
27+
Value proposition
28+
=================
29+
30+
Computer vision profile is made to simplify creation of products which
31+
need to employ computer vision technologies. We don't provide any custom
32+
components, but instead we focus our efforts into making sure the
33+
integration of open source components is as seamless as possible.
34+
35+
We especially aim to:
36+
37+
#. Create demos which provide starting points for product development.
38+
#. Make sure the different computer vision components are scriptable with the
39+
same scripting language, making it possible to create demos and
40+
proof-of-concepts utilizing different computer vision techniques. We have
41+
selected Python 3 to be this language. NumPy matrixes are the common format
42+
for sharing image data between different libraries.
43+
#. Provide hardware acceleration using OpenCL and Intel-specific
44+
technologies for the components which support them.
45+
#. Select components thoughtfully, keeping in mind their licensing and
46+
security history. Computer vision profile's production configuration doesn't
47+
depend on any components which use (L)GPLv3 license, making it easier
48+
to employ technologies such as Secure Boot.
49+
50+
Key components
51+
==============
52+
53+
`OpenCV <http://opencv.org/>`_ is the backbone of the open source computer
54+
vision software components. We integrate it with some extra configuraton. We add
55+
`gstreamer-vaapi <https://gstreamer.freedesktop.org/modules/gstreamer-vaapi.html>`_
56+
for Intel-accelerated video encoding, decoding, and processing. Intel RealSense
57+
camera support is provided by
58+
`librealsense <https://github.com/IntelRealSense/librealsense>`_.
59+
60+
In addition to this, we add OpenCL hardware acceleration capabilities with
61+
`Beignet <https://www.freedesktop.org/wiki/Software/Beignet/>`_. It can be
62+
accessed using `ViennaCL lineal algebra library <http://viennacl.sourceforge.net/>`_.
63+
64+
Computer vision profile's production configuration contains examples and samples
65+
for OpenCV, librealsense, and OpenCL, allowing users to validate that the
66+
subsystems work and run some benchmarks.
67+
68+
The ``meta-refkit-extra`` layer contains `Caffe deep learning framework
69+
<http://caffe.berkeleyvision.org/>`_, which can be used for image classification
70+
and even training DNN models, though training is slow on IoT devices. The layer
71+
also contains Python 3 bindings for librealsense and some Python 3 image
72+
processing libraries (`ImageIO <https://imageio.github.io/>`_ and `Pillow
73+
<https://python-pillow.org/>`_).
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/env python
2+
# ex:ts=4:sw=4:sts=4:et
3+
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4+
#
5+
# Copyright (c) 2017, Intel Corporation.
6+
# All rights reserved.
7+
#
8+
# This program is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License version 2 as
10+
# published by the Free Software Foundation.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License along
18+
# with this program; if not, write to the Free Software Foundation, Inc.,
19+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
#
21+
# AUTHORS
22+
# Ismo Puustinen <ismo.puustinen@intel.com>
23+
#
24+
# Based on meta/lib/oeqa/selftest/* and meta-refkit/lib/oeqa/selftest/*
25+
26+
"""Tests for Reference Kit image licensing. Contains a test case for
27+
computer vision production image without GPLv3 components."""
28+
29+
# Important: This test does by no means guarantee that there is license
30+
# compliance. Having the license compatibility rules in a map is not precise
31+
# enough, and many licenses are just omitted. This test is just meant to help
32+
# detect obvious image problems, and it might not do even that in all cases.
33+
# Especially the dual-licensing rules are not very accurate due to the way
34+
# Bitbake recipes express dual-licensing and multi-licensing.
35+
36+
from oeqa.selftest.base import oeSelfTest
37+
from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars, runqemu
38+
import licensecheck
39+
import glob
40+
41+
class LicensingTest(oeSelfTest):
42+
"""Licensing test class."""
43+
44+
def _analyzePackages(self, packageNames, whitelistFile, prohibited):
45+
checker = licensecheck.LicenseCheck(whitelistFile, prohibited)
46+
47+
# Process packages which are installed to the image.
48+
49+
for name in packageNames:
50+
print("Processing package %s..." % name)
51+
52+
# We can safely skip the kernel modules, also works around kernel
53+
# naming issues.
54+
if name.startswith("kernel"):
55+
continue
56+
57+
# Pam has some packaging issues, leading to "package not
58+
# found" error messages.
59+
if name.startswith("libpam") or name.startswith("pam"):
60+
continue
61+
62+
# Packagegroups do not have licensing in the sense that we
63+
# are interested in.
64+
if name.startswith("packagegroup"):
65+
continue
66+
67+
# Lots of custom licenses, can't really be automatically
68+
# checked.
69+
if name.startswith("linux-firmware"):
70+
continue
71+
72+
self.assertTrue(checker.testPackage(name), msg="License check for package %s failed" % name)
73+
74+
def _get_latest_manifest(self, imagename, deploydir):
75+
# A hack for finding the correct package.manifest for the image we just
76+
# baked. Assume that has the latest timestamp. First, remove the
77+
# timestamp from image name:
78+
imagename_without_timestamp = ("-").join(imagename.split("-")[:-1])
79+
# Find the corresponding files:
80+
path = os.path.join(deploydir, "licenses", imagename_without_timestamp)
81+
# Sort them (by time stamp):
82+
candidates = glob.glob(path + "*")
83+
candidates.sort()
84+
# Get the latest:
85+
manifestdir = candidates[-1]
86+
87+
return os.path.join(manifestdir, "package.manifest")
88+
89+
def test_check_computervision_licensing(self):
90+
91+
""" Check that computer vision production build image can be
92+
made without using GPLv3 family licenses in any component.
93+
"""
94+
95+
test_image = 'refkit-image-computervision'
96+
97+
print("test_check_computervision_licensing")
98+
99+
# Create the test image (rootfs is enough).
100+
print('Building test image (%s)...' % test_image)
101+
102+
# Get variables from BB and initialize package list.
103+
bb_vars = get_bb_vars(["DEPLOY_DIR", "IMAGE_NAME", "META_REFKIT_BASE", "META_REFKIT_CORE_BASE"], test_image)
104+
deploydir = bb_vars["DEPLOY_DIR"]
105+
imagename = bb_vars["IMAGE_NAME"]
106+
basedir = bb_vars["META_REFKIT_BASE"]
107+
coredir = bb_vars["META_REFKIT_CORE_BASE"]
108+
109+
self.append_config('IMAGE_MODE="production"')
110+
self.append_config('IMAGE_MODE_SUFFIX="-production"')
111+
self.append_config('REFKIT_DMVERITY_PRIVATE_KEY = "' + os.path.join(coredir, 'files/dm-verity/private.pem') + '"')
112+
self.append_config('REFKIT_DMVERITY_PASSWORD = "pass:refkit"')
113+
114+
# Create the root filesystem. It's enough for getting a package
115+
# list.
116+
bitbake('-c rootfs %s' % test_image)
117+
118+
# Find package list manifest.
119+
manifest = self._get_latest_manifest(imagename, deploydir)
120+
self.assertTrue(os.path.isfile(manifest), msg="No manifest file created for image. It should have been created in %s" % manifest)
121+
122+
# Find whitelist.
123+
whitelist = os.path.join(basedir, "../meta-iotqa/scripts/contrib/licensetree-whitelist.txt")
124+
self.assertTrue(os.path.isfile(whitelist), msg="Whitelist file not found. It should have been in %s" % whitelist)
125+
126+
lines = []
127+
128+
with open(manifest) as f:
129+
lines = f.readlines()
130+
131+
packageNames = [line.split()[0] for line in lines]
132+
133+
# GPLv3 and LGPLv3 are not allowed in this image.
134+
prohibited=["GPLv3", "LGPLv3"]
135+
136+
self._analyzePackages(packageNames, whitelist, prohibited)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
virtual/update-alternatives
2+
make
3+
libtool-cross
4+
ptest-runner-dev
5+
ptest-runner
6+
virtual/gettext
7+
perl
8+
base-files
9+
cryptodev-linux
10+
shadow
11+
shadow-sysroot
12+
update-rc.d
13+
initscripts
14+
bash-completion
15+
iptables
16+
nftables
17+
ppp
18+
wpa-supplicant
19+
cpp
20+
ofono
21+
bluez5
22+
connman
23+
util-linux
24+
udev
25+
libgcc-initial
26+
linux-libc-headers
27+
python-core
28+
python3-core
29+
libpam-suffix
30+
libpam-runtime
31+
libpam
32+
base-passwd
33+
opkg-utils
34+
bc

meta-refkit-computervision/recipes-opencl/beignet/beignet.inc

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ BBCLASSEXTEND = "native"
1212

1313
# CMake cannot digest "+" in pathes -> replace it with dots.
1414
PV = "1.3.1.${@ 'git${SRCPV}'.replace('+', '.')}"
15-
SRCREV = "beaf26ff429bd8660d2103fb682243efeb828ab1"
15+
SRCREV = "6804cca263edd11fd03b2d7f5b7ba034d9a013c3"
1616
S = "${WORKDIR}/git"
1717

1818
# we need to depend on ocl-icd, so that the exported symbols go right
@@ -24,17 +24,7 @@ DEPENDS_class-native = "clang-native"
2424

2525
CL_HW_TARGET ?= "${@d.getVar('PN').split('-')[1]}"
2626

27-
# built-in kernels depend on libocl's headers (e.g. ocl_as.h) yet there is no
28-
# dependency specified for that in beignet's build system. This causes race
29-
# condition when libgbe.so is compiled for the target.
30-
PARALLEL_MAKE = ""
31-
32-
inherit cmake pkgconfig
33-
34-
# There is no python in sysroot -> look for it on the build host.
35-
# WARNING: remove CLang from the host otherwise it might get into use
36-
# instead of the one from meta-clang.
37-
OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "BOTH"
27+
inherit cmake pkgconfig pythonnative
3828

3929
EXTRA_OECMAKE = " -DSTANDALONE_GBE_COMPILER_DIR=${STAGING_BINDIR_NATIVE} -DLLVM_LIBRARY_DIR=${STAGING_LIBDIR} -DBEIGNET_INSTALL_DIR=${libdir}/beignet-${CL_HW_TARGET}"
4030
EXTRA_OECMAKE_class-native = " -DBEIGNET_INSTALL_DIR=/usr/lib/beignet -DLLVM_LIBRARY_DIR=${STAGING_LIBDIR_NATIVE}"

0 commit comments

Comments
 (0)