Skip to content

Commit 4c145c9

Browse files
authored
Samples (#20)
* Adding third party dep on opencv * Adding opencv target in openvx * Adding openvx samples * Document update to opencv target * Got opencv orb sample to run * More readme updates * fixed build issue on linux and asan warning * Fixed typo * fix unit test
1 parent e0d207c commit 4c145c9

File tree

124 files changed

+26142
-39
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+26142
-39
lines changed

MODULE.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ module(
88
)
99

1010
# Import external dependencies
11-
bazel_dep(name = "rules_cc", version = "0.1.0")
11+
bazel_dep(name = "rules_cc", version = "0.1.1")
1212
bazel_dep(name = "rules_foreign_cc", version = "0.11.1")
1313
bazel_dep(name = "rules_python", version = "0.40.0")
14-
bazel_dep(name = "platforms", version = "0.0.10")
14+
bazel_dep(name = "platforms", version = "0.0.11")
1515
bazel_dep(name = "googletest", version = "1.15.2")
1616
bazel_dep(name = "apple_support", version = "1.17.1", repo_name = "build_bazel_apple_support")
1717
bazel_dep(name = "curl", version = "8.8.0")
1818
bazel_dep(name = "nlohmann_json", version = "3.11.3")
1919
bazel_dep(name = "hedron_compile_commands", dev_dependency = True)
2020
bazel_dep(name = "flatbuffers", version = "24.3.25")
2121
bazel_dep(name = "opentelemetry-cpp", version = "1.19.0")
22+
bazel_dep(name = "opencv", version = "4.11.0.bcr.2")
2223

2324
# Hedron's Compile Commands Extractor for Bazel
2425
git_override(

MODULE.bazel.lock

Lines changed: 15 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Doxyfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,7 @@ FULL_SIDEBAR = NO
18101810
# Minimum value: 0, maximum value: 20, default value: 4.
18111811
# This tag requires that the tag GENERATE_HTML is set to YES.
18121812

1813-
ENUM_VALUES_PER_LINE = 4
1813+
ENUM_VALUES_PER_LINE = 1
18141814

18151815
# When the SHOW_ENUM_VALUES tag is set doxygen will show the specified
18161816
# enumeration values besides the enumeration mnemonics.
@@ -2813,7 +2813,7 @@ DIR_GRAPH_MAX_DEPTH = 1
28132813
# The default value is: png.
28142814
# This tag requires that the tag HAVE_DOT is set to YES.
28152815

2816-
DOT_IMAGE_FORMAT = png
2816+
DOT_IMAGE_FORMAT = svg
28172817

28182818
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
28192819
# enable generation of interactive SVG images that allow zooming and panning.

framework/include/vx_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
/*! \brief Maximum number of parameters to a kernel.
156156
* \ingroup group_int_defines
157157
*/
158-
#define VX_INT_MAX_PARAMS (15)
158+
#define VX_INT_MAX_PARAMS (22)
159159

160160
/*! \brief Maximum number of loadable modules.
161161
* \ingroup group_int_defines

framework/src/vx_kernel.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ VX_API_ENTRY vx_status VX_API_CALL vxLoadKernels(vx_context context, const vx_ch
341341
status = publish((vx_context)context);
342342
if (status != VX_SUCCESS)
343343
{
344-
VX_PRINT(VX_ZONE_ERROR, "Failed to publish kernels in module\n");
344+
VX_PRINT(VX_ZONE_ERROR,
345+
"Failed to publish kernels in module with status %d\n", status);
345346
Osal::unloadModule(context->modules[m].handle);
346347
context->modules[m].handle = nullptr;
347348
}
@@ -875,6 +876,8 @@ VX_API_ENTRY vx_status VX_API_CALL vxAddParameterToKernel(vx_kernel kernel,
875876
(Parameter::isValidDirection(dir) == vx_false_e) ||
876877
(Parameter::isValidState(state) == vx_false_e))
877878
{
879+
VX_PRINT(VX_ZONE_ERROR,
880+
"Invalid data type, param direction, or param state!\n");
878881
status = VX_ERROR_INVALID_PARAMETERS;
879882
}
880883
else
@@ -893,6 +896,8 @@ VX_API_ENTRY vx_status VX_API_CALL vxAddParameterToKernel(vx_kernel kernel,
893896
(Parameter::isValidState(state) == vx_false_e)) ||
894897
(data_type == VX_TYPE_DELAY && dir != VX_INPUT))
895898
{
899+
VX_PRINT(VX_ZONE_ERROR,
900+
"Invalid data type, param direction, or param state!\n");
896901
status = VX_ERROR_INVALID_PARAMETERS;
897902
}
898903
else
@@ -906,6 +911,7 @@ VX_API_ENTRY vx_status VX_API_CALL vxAddParameterToKernel(vx_kernel kernel,
906911
}
907912
else
908913
{
914+
VX_PRINT(VX_ZONE_ERROR, "Invalid number of parameters associated!\n");
909915
status = VX_ERROR_INVALID_PARAMETERS;
910916
}
911917
}

framework/src/vx_parameter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Parameter::~Parameter()
3434

3535
vx_bool Parameter::isValidDirection(vx_enum dir)
3636
{
37-
if ((dir == VX_INPUT) || (dir == VX_OUTPUT)) /* Bidirectional is not valid for user kernels */
37+
if ((dir == VX_INPUT) || (dir == VX_OUTPUT) || (dir == VX_BIDIRECTIONAL))
3838
{
3939
return vx_true_e;
4040
}

include/VX/vx_corevx_ext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@
171171
*/
172172

173173
/*!
174-
* \brief The OpenVX CoreVX Vendor Extension.
175-
* \defgroup group_corevx_ext Extension: CoreVX
174+
* \brief The OpenVX EdgeAI Vendor Extension.
175+
* \defgroup group_corevx_ext Extension: AI/ML
176176
* \ingroup group_extensions
177177
*
178178
* \defgroup group_ort_function_cpu_inference Kernel: ORT Inference

samples/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
2+
3+
<p align="center"><img width="50%" src="https://upload.wikimedia.org/wikipedia/commons/d/dd/OpenVX_logo.svg" /></p>
4+
5+
# Sample Applications
6+
7+
<a href="https://www.khronos.org/openvx/" target="_blank">Khronos OpenVX™</a> is an open, royalty-free standard for cross-platform acceleration of computer vision applications. OpenVX enables performance and power-optimized computer vision processing, especially important in embedded and real-time use cases such as face, body, and gesture tracking, smart video surveillance, advanced driver assistance systems (ADAS), object and scene reconstruction, augmented reality, visual inspection, robotics and more.
8+
9+
In this project, we provide samples that use our optimized libraries to build applications that showcase potential usage or may used as reference to develop your own products.
10+
11+
## Bubble Pop
12+
13+
In this sample we will create an OpenVX graph to run Bubble Pop on a live camera. This sample application uses <a href="https://en.wikipedia.org/wiki/OpenCV" target="_blank">OpenCV</a> to decode input image, draw bubbles/donuts and display the output.
14+
15+
<p align="center"><img width="60%" src="images/vx-pop-app.gif" /></p>
16+
17+
## Canny Edge Detector
18+
19+
In this sample we will create an OpenVX graph to run canny edge detection on an image or a live camera. This sample application uses <a href="https://en.wikipedia.org/wiki/OpenCV" target="_blank">OpenCV</a> to decode input image and display the output.
20+
21+
<p align="center"><img width="60%" src="images/canny_image.PNG" /></p>
22+
23+
## Optical Flow
24+
25+
This sample [application](./optical_flow/README.md#openvx-samples) we will create an OpenVX graph to run Optical Flow on a video/live. This sample application uses <a href="https://en.wikipedia.org/wiki/OpenCV" target="_blank">OpenCV</a> to decode input video and display the output.
26+
27+
<p align="center"> <img width="60%" src="https://raw.githubusercontent.com/ROCm/MIVisionX/master/docs/data/optical_flow_video.gif"> </p>
28+
29+
## Skin Tone Detector
30+
31+
In this sample we will create an OpenVX graph to run skintone detection on an image or a live camera. This sample application uses <a href="https://en.wikipedia.org/wiki/OpenCV" target="_blank">OpenCV</a> to decode input image and display the output.
32+
33+
<p align="center"><img width="60%" src="images/skintone-detect-app.png" /></p>
34+
35+
## ORB (Oriented FAST and Rotated BRIEF)
36+
In this sample we will create an OpenVX graph to run ORB (Oriented FAST and Rotated BRIEF) on a live camera. This sample application uses <a href="https://en.wikipedia.org/wiki/OpenCV" target="_blank">OpenCV</a> to detect and display keypoints.
37+
38+
<p align="center"><img width="60%" src="images/orb_kp.jpg" /></p>

samples/bubble-pop/BUILD

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
2+
3+
cc_import(
4+
name = "import_vx_pop",
5+
shared_library = ":vx_pop",
6+
)
7+
8+
cc_shared_library(
9+
name = "vx_pop",
10+
deps = [":vx_pop_a"]
11+
)
12+
13+
cc_library(
14+
name = "vx_pop_a",
15+
srcs = [
16+
"source/AMD_VX_Pop_Bubble.cpp",
17+
"source/AMD_VX_Pop_Donut.cpp",
18+
"source/internal_dataTranslator.cpp",
19+
"source/internal_publishKernels.cpp",
20+
"source/internal_vxNodes.cpp"
21+
],
22+
deps = [
23+
"//:corevx",
24+
"@opencv",
25+
"//targets/ai_server:imported_openvx_ai_server",
26+
"//targets/c_model:imported_openvx_c_model",
27+
"//targets/debug:imported_openvx_debug",
28+
"//targets/extras:imported_openvx_extras",
29+
"//targets/liteRT:imported_openvx_liteRT",
30+
"//targets/opencl:imported_openvx_opencl",
31+
"//targets/onnxRT:imported_openvx_onnxRT",
32+
"//targets/executorch:imported_openvx_torch",
33+
"//third_party:opencv-prebuilt",
34+
],
35+
hdrs = glob([
36+
"include/*.h"
37+
]),
38+
includes = ["include"],
39+
)
40+
41+
cc_binary(
42+
name = "bubble-pop",
43+
srcs = [
44+
"source/AMD_app.cpp",
45+
"include/vx_ext_pop.h",
46+
"include/vx_pop.h",
47+
],
48+
includes = ["include"],
49+
data = [
50+
"image/bubble.png",
51+
],
52+
deps = [
53+
":vx_pop_a",
54+
":import_vx_pop"
55+
],
56+
visibility = ["//visibility:public"],
57+
)

samples/bubble-pop/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## Bubble Pop Sample
2+
In this sample we will create an OpenVX graph to run Bubble Pop on a live camera. This sample application uses <a href="https://en.wikipedia.org/wiki/OpenCV" target="_blank">OpenCV</a> to decode input image, draw bubbles/donuts and display the output.
3+
4+
<p align="center"><img width="60%" src="../images/vx-pop-app.gif" /></p>
5+
6+
### Prerequisites
7+
8+
* [Conformant OpenVX Implementation](https://github.com/KhronosGroup/Khronosdotorg/blob/master/api/openvx/resources.md)
9+
10+
* [OpenCV](https://github.com/opencv/opencv/releases/tag/3.4.0)
11+
12+
* Camera
13+
14+
### Steps to run the Bubble Pop sample
15+
16+
* **Step - 1:** Build and install [Conformant OpenVX Implementation](https://github.com/KhronosGroup/OpenVX-sample-impl). In this example we will use the OpenVX Sample Implementation available on [GitHub](https://github.com/KhronosGroup/OpenVX-sample-impl)
17+
18+
```
19+
Build OpenVX on Linux
20+
21+
* Git Clone project with a recursive flag to get submodules
22+
23+
git clone --recursive https://github.com/KhronosGroup/OpenVX-sample-impl.git
24+
25+
* Use Build.py script
26+
27+
cd OpenVX-sample-impl/
28+
python Build.py --os=Linux --arch=64 --conf=Debug --conf_vision --enh_vision --conf_nn
29+
```
30+
31+
* **Step - 2:** Export OpenVX Directory Path
32+
33+
```
34+
export OPENVX_DIR=$(pwd)/install/Linux/x64/Debug
35+
```
36+
37+
* **Step - 3:** Clone the OpenVX Samples project and build the bubble pop application
38+
39+
```
40+
cd ~/ && mkdir OpenVXSample-pop
41+
cd OpenVXSample-pop/
42+
git clone https://github.com/kiritigowda/openvx-samples.git
43+
```
44+
45+
* **Step - 4:** CMake and Build the pop application
46+
47+
```
48+
mkdir pop-build && cd pop-build
49+
cmake -DOPENVX_INCLUDES=$OPENVX_DIR/include -DOPENVX_LIBRARIES=$OPENVX_DIR/bin/libopenvx.so ../openvx-samples/bubble-pop/
50+
make
51+
```
52+
53+
* **Step - 5:** Run VX Pop application
54+
55+
* **Bubbles**
56+
57+
```
58+
./vxPop --bubble
59+
```
60+
61+
* **Donuts**
62+
63+
````
64+
./vxPop --donut
65+
````

0 commit comments

Comments
 (0)