aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorMichalis Spyrou <michalis.spyrou@arm.com>2021-02-16 11:34:39 +0000
committerGeorgios Pinitas <georgios.pinitas@arm.com>2021-02-23 10:58:31 +0000
commit27e67f0b2047cfa2f011f9e242e3068d9e106b39 (patch)
tree1d0183973b38541fc91c64c12a694eb67dd5059b /examples
parent0ad0129da3e89097cde817e22140fc463ae43309 (diff)
downloadComputeLibrary-27e67f0b2047cfa2f011f9e242e3068d9e106b39.tar.gz
Remove Compute Vision Neon support
Resolves COMPMID-4150 Change-Id: I316e8ab97de796666c71eadfde894715fcf4a1aa Signed-off-by: Michalis Spyrou <michalis.spyrou@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5141 Tested-by: Arm Jenkins <bsgcomp@arm.com> Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/neon_cartoon_effect.cpp115
-rw-r--r--examples/neon_opticalflow.cpp263
-rw-r--r--examples/neoncl_scale_median_gaussian.cpp142
3 files changed, 0 insertions, 520 deletions
diff --git a/examples/neon_cartoon_effect.cpp b/examples/neon_cartoon_effect.cpp
deleted file mode 100644
index 24a689bee9..0000000000
--- a/examples/neon_cartoon_effect.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2017-2020 Arm Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include "arm_compute/runtime/NEON/NEFunctions.h"
-
-#include "arm_compute/core/Types.h"
-#include "utils/ImageLoader.h"
-#include "utils/Utils.h"
-
-using namespace arm_compute;
-using namespace utils;
-
-class NEONCartoonEffectExample : public Example
-{
-public:
- bool do_setup(int argc, char **argv) override
- {
- // Open PPM file
- PPMLoader ppm;
-
- if(argc < 2)
- {
- // Print help
- std::cout << "Usage: ./build/neon_cartoon_effect [input_image.ppm]\n\n";
- std::cout << "No input_image provided, creating a dummy 640x480 image\n";
- // Create an empty grayscale 640x480 image
- src_img.allocator()->init(TensorInfo(640, 480, Format::U8));
- }
- else
- {
- ppm.open(argv[1]);
- ppm.init_image(src_img, Format::U8);
- }
-
- // Initialize just the dimensions and format of the images:
- gaus5x5_img.allocator()->init(*src_img.info());
- canny_edge_img.allocator()->init(*src_img.info());
- dst_img.allocator()->init(*src_img.info());
-
- // Configure the functions to call
- gaus5x5.configure(&src_img, &gaus5x5_img, BorderMode::REPLICATE);
- canny_edge.configure(&src_img, &canny_edge_img, 100, 80, 3, 1, BorderMode::REPLICATE);
- sub.configure(&gaus5x5_img, &canny_edge_img, &dst_img, ConvertPolicy::SATURATE);
-
- // Now that the padding requirements are known we can allocate the images:
- src_img.allocator()->allocate();
- dst_img.allocator()->allocate();
- gaus5x5_img.allocator()->allocate();
- canny_edge_img.allocator()->allocate();
-
- // Fill the input image with the content of the PPM image if a filename was provided:
- if(ppm.is_open())
- {
- ppm.fill_image(src_img);
- output_filename = std::string(argv[1]) + "_out.ppm";
- }
-
- return true;
- }
-
- void do_run() override
- {
- // Execute the functions:
- gaus5x5.run();
- canny_edge.run();
- sub.run();
- }
-
- void do_teardown() override
- {
- // Save the result to file:
- if(!output_filename.empty())
- {
- save_to_ppm(dst_img, output_filename); // save_to_ppm maps and unmaps the image to store as PPM
- }
- }
-
-private:
- Image src_img{}, dst_img{}, gaus5x5_img{}, canny_edge_img{};
- NEGaussian5x5 gaus5x5{};
- NECannyEdge canny_edge{};
- NEArithmeticSubtraction sub{};
- std::string output_filename{};
-};
-
-/** Main program for cartoon effect test
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Path to PPM image to process )
- */
-int main(int argc, char **argv)
-{
- return utils::run_example<NEONCartoonEffectExample>(argc, argv);
-}
diff --git a/examples/neon_opticalflow.cpp b/examples/neon_opticalflow.cpp
deleted file mode 100644
index ff9478cc18..0000000000
--- a/examples/neon_opticalflow.cpp
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2019 Arm Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#include "arm_compute/runtime/NEON/NEFunctions.h"
-
-#include "arm_compute/core/Types.h"
-#include "utils/ImageLoader.h"
-#include "utils/Utils.h"
-
-#include <fstream>
-#include <sstream>
-#include <vector>
-
-using namespace arm_compute;
-using namespace utils;
-
-class NeonOpticalFlowExample : public Example
-{
-public:
- NeonOpticalFlowExample()
- : input_points(100), output_points(100), point_estimates(100)
- {
- }
-
- bool do_setup(int argc, char **argv) override
- {
- if(argc < 5)
- {
- // Print help
- std::cout << "Usage: ./build/neon_opticalflow [src_1st.ppm] [src_2nd.ppm] [keypoints] [estimates]\n\n";
- const unsigned int img_width = 64;
- const unsigned int img_height = 64;
- const unsigned int rect_x = 20;
- const unsigned int rect_y = 40;
- const unsigned int rect_s = 8;
- const unsigned int offsetx = 24;
- const unsigned int offsety = 3;
- std::cout << "No input_image provided, creating test data:\n";
- std::cout << "\t Image src_1st = (" << img_width << "," << img_height << ")" << std::endl;
- std::cout << "\t Image src_2nd = (" << img_width << "," << img_height << ")" << std::endl;
- init_img(src_1st, img_width, img_height, rect_x, rect_y, rect_s);
- init_img(src_2nd, img_width, img_height, rect_x + offsetx, rect_y + offsety, rect_s);
- const int num_points = 4;
- input_points.resize(num_points);
- point_estimates.resize(num_points);
- const std::array<unsigned int, num_points> tracking_coordsx = { rect_x - 1, rect_x, rect_x + 1, rect_x + 2 };
- const std::array<unsigned int, num_points> tracking_coordsy = { rect_y - 1, rect_y, rect_y + 1, rect_y + 2 };
- const std::array<unsigned int, num_points> estimate_coordsx = { rect_x + offsetx - 1, rect_x + offsetx, rect_x + offsetx + 1, rect_x + offsetx + 2 };
- const std::array<unsigned int, num_points> estimate_coordsy = { rect_y + offsety - 1, rect_y + offsety, rect_y + offsety + 1, rect_y + offsety + 2 };
-
- for(int k = 0; k < num_points; ++k)
- {
- auto &keypoint = input_points.at(k);
- keypoint.x = tracking_coordsx[k];
- keypoint.y = tracking_coordsy[k];
- keypoint.tracking_status = 1;
- }
- for(int k = 0; k < num_points; ++k)
- {
- auto &keypoint = point_estimates.at(k);
- keypoint.x = estimate_coordsx[k];
- keypoint.y = estimate_coordsy[k];
- keypoint.tracking_status = 1;
- }
- }
- else
- {
- load_ppm(argv[1], src_1st);
- load_ppm(argv[2], src_2nd);
- load_keypoints(argv[3], input_points);
- load_keypoints(argv[4], point_estimates);
- }
-
- print_points(input_points, "Tracking points : ");
- print_points(point_estimates, "Estimates points : ");
-
- const unsigned int num_levels = 3;
- // Initialise and allocate pyramids
- PyramidInfo pyramid_info(num_levels, SCALE_PYRAMID_HALF, src_1st.info()->tensor_shape(), src_1st.info()->format());
- pyr_1st.init_auto_padding(pyramid_info);
- pyr_2nd.init_auto_padding(pyramid_info);
-
- pyrf_1st.configure(&src_1st, &pyr_1st, BorderMode::UNDEFINED, 0);
- pyrf_2nd.configure(&src_2nd, &pyr_2nd, BorderMode::UNDEFINED, 0);
-
- output_points.resize(input_points.num_values());
-
- optkf.configure(&pyr_1st, &pyr_2nd,
- &input_points, &point_estimates, &output_points,
- Termination::TERM_CRITERIA_BOTH, 0.01f, 15, 5, true, BorderMode::UNDEFINED, 0);
-
- pyr_1st.allocate();
- pyr_2nd.allocate();
-
- return true;
- }
- void do_run() override
- {
- //Execute the functions:
- pyrf_1st.run();
- pyrf_2nd.run();
- optkf.run();
- }
- void do_teardown() override
- {
- print_points(output_points, "Output points : ");
- }
-
-private:
- /** Loads the input keypoints from a file into an array
- *
- * @param[in] fn Filename containing the keypoints. Each line must have two values X Y.
- * @param[out] img Reference to an unintialised KeyPointArray
- */
- bool load_keypoints(const std::string &fn, KeyPointArray &array)
- {
- assert(!fn.empty());
- std::ifstream f(fn);
- if(f.is_open())
- {
- std::cout << "Reading points from " << fn << std::endl;
- std::vector<KeyPoint> v;
- for(std::string line; std::getline(f, line);)
- {
- std::stringstream ss(line);
- std::string xcoord;
- std::string ycoord;
- getline(ss, xcoord, ' ');
- getline(ss, ycoord, ' ');
- KeyPoint kp;
- kp.x = std::stoi(xcoord);
- kp.y = std::stoi(ycoord);
- kp.tracking_status = 1;
- v.push_back(kp);
- }
- const int num_points = v.size();
- array.resize(num_points);
- for(int k = 0; k < num_points; ++k)
- {
- auto &keypoint = array.at(k);
- keypoint = v[k];
- }
- return true;
- }
- else
- {
- std::cout << "Cannot open keypoints file " << fn << std::endl;
- return false;
- }
- }
-
- /** Creates and Image and fills it with the ppm data from the file
- *
- * @param[in] fn PPM filename to be loaded
- * @param[out] img Reference to an unintialised image instance
- */
- bool load_ppm(const std::string &fn, Image &img)
- {
- assert(!fn.empty());
- PPMLoader ppm;
- ppm.open(fn);
- ppm.init_image(img, Format::U8);
- img.allocator()->allocate();
- if(ppm.is_open())
- {
- std::cout << "Reading image " << fn << std::endl;
- ppm.fill_image(img);
- return true;
- }
- else
- {
- std::cout << "Cannot open " << fn << std::endl;
- return false;
- }
- }
- /** Creates and Image and draws a square in the specified coordinares.
- *
- * @param[out] img Reference to an unintialised image instance
- * @param[in] img_width Width of the image to be created
- * @param[in] img_height Height of the image to be created
- * @param[in] square_center_x Coordinate along x-axis to be used as the center for the square
- * @param[in] square_center_y Coordinate along y-axis to be used as the center for the square
- * @param[in] square_size Size in pixels to be used for the square
- */
- void init_img(Image &img, unsigned int img_width, unsigned int img_height,
- unsigned int square_center_x, unsigned int square_center_y,
- unsigned int square_size)
- {
- img.allocator()->init(TensorInfo(img_width, img_height, Format::U8));
- img.allocator()->allocate();
- const unsigned int square_half = square_size / 2;
- // assert the square is in the bounds of the image
- assert(square_center_x > square_half && square_center_x + square_half < img_width);
- assert(square_center_y > square_half && square_center_y + square_half < img_height);
- // get ptr to the top left pixel for the squeare
- std::fill(img.buffer(), img.buffer() + img_width * img_height, 0);
- for(unsigned int i = 0; i < square_size; ++i)
- {
- for(unsigned int j = 0; j < square_size; ++j)
- {
- uint8_t *ptr = img.ptr_to_element(Coordinates(square_center_x - square_half + j, square_center_y - square_half + i));
- *ptr = 0xFF;
- }
- }
- }
- /** Prints an array of keypoints and an optional label
- *
- * @param[in] a Keypoint array to be printed
- * @param[in] str Label to be printed before the array
- */
- void print_points(const KeyPointArray &a, const std::string &str = "")
- {
- std::cout << str << std::endl;
- for(unsigned int k = 0; k < a.num_values(); ++k)
- {
- auto kp = a.at(k);
- std::cout << "\t "
- << " (x,y) = (" << kp.x << "," << kp.y << ")";
- std::cout << " strength = " << kp.strength << " "
- << " scale = " << kp.scale << " orientation " << kp.orientation << " status " << kp.tracking_status << " err = " << kp.error << std::endl;
- }
- }
-
- Pyramid pyr_1st{};
- Pyramid pyr_2nd{};
- NEGaussianPyramidHalf pyrf_1st{};
- NEGaussianPyramidHalf pyrf_2nd{};
- NEOpticalFlow optkf{};
- Image src_1st{}, src_2nd{};
- KeyPointArray input_points;
- KeyPointArray output_points;
- KeyPointArray point_estimates;
-};
-
-/** Main program for optical flow test
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Path to PPM image to process )
- */
-int main(int argc, char **argv)
-{
- return utils::run_example<NeonOpticalFlowExample>(argc, argv);
-}
diff --git a/examples/neoncl_scale_median_gaussian.cpp b/examples/neoncl_scale_median_gaussian.cpp
deleted file mode 100644
index 2580a35f24..0000000000
--- a/examples/neoncl_scale_median_gaussian.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (c) 2016-2021 Arm Limited.
- *
- * SPDX-License-Identifier: MIT
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */
-#error "This example needs to be built with -DARM_COMPUTE_CL"
-#endif /* ARM_COMPUTE_CL */
-
-#include "arm_compute/core/Types.h"
-#include "arm_compute/runtime/CL/CLScheduler.h"
-#include "arm_compute/runtime/CL/functions/CLGaussian5x5.h"
-#include "arm_compute/runtime/CL/functions/CLScale.h"
-#include "arm_compute/runtime/NEON/NEFunctions.h"
-#include "utils/ImageLoader.h"
-#include "utils/Utils.h"
-
-using namespace arm_compute;
-using namespace utils;
-
-/** Example demonstrating how to use both CL and Neon functions in the same pipeline
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Path to PPM image to process )
- */
-class NEONCLScaleMedianGaussianExample : public Example
-{
-public:
- bool do_setup(int argc, char **argv) override
- {
- /** [Neon / OpenCL Interop] */
- PPMLoader ppm;
-
- CLScheduler::get().default_init();
-
- if(argc < 2)
- {
- // Print help
- std::cout << "Usage: ./build/cl_convolution [input_image.ppm]\n\n";
- std::cout << "No input_image provided, creating a dummy 640x480 image\n";
- // Create an empty grayscale 640x480 image
- src.allocator()->init(TensorInfo(640, 480, Format::U8));
- }
- else
- {
- ppm.open(argv[1]);
- ppm.init_image(src, Format::U8);
- }
-
- TensorInfo scale_median_info(TensorInfo(src.info()->dimension(0) / 2, src.info()->dimension(1) / 2, Format::U8));
-
- // Configure the temporary and destination images
- scale_median.allocator()->init(scale_median_info);
- median_gauss.allocator()->init(scale_median_info);
- dst.allocator()->init(scale_median_info);
-
- scale.configure(&src, &scale_median, ScaleKernelInfo{ InterpolationPolicy::NEAREST_NEIGHBOR, BorderMode::REPLICATE });
- median.configure(&scale_median, &median_gauss, BorderMode::REPLICATE);
- gauss.configure(&median_gauss, &dst, BorderMode::REPLICATE);
-
- // Allocate all the images
- src.allocator()->allocate();
- scale_median.allocator()->allocate();
- median_gauss.allocator()->allocate();
- dst.allocator()->allocate();
-
- // Fill the input image with the content of the PPM image if a filename was provided:
- if(ppm.is_open())
- {
- ppm.fill_image(src);
- const std::string output_filename = std::string(argv[1]) + "_out.ppm";
- }
- /** [Neon / OpenCL Interop] */
-
- return true;
- }
- void do_run() override
- {
- // Enqueue and flush the OpenCL kernel:
- scale.run();
-
- // Do a blocking map of the input and output buffers of the Neon function:
- scale_median.map();
- median_gauss.map();
-
- // Run the Neon function:
- median.run();
-
- // Unmap the output buffer before it's used again by OpenCL:
- scale_median.unmap();
- median_gauss.unmap();
-
- // Run the final OpenCL function:
- gauss.run();
-
- // Make sure all the OpenCL jobs are done executing:
- CLScheduler::get().sync();
- }
- void do_teardown() override
- {
- // Save the result to file:
- if(!output_filename.empty())
- {
- save_to_ppm(dst, output_filename); // save_to_ppm maps and unmaps the image to store as PPM
- }
- }
-
-private:
- CLImage src{}, scale_median{}, median_gauss{}, dst{};
- CLScale scale{};
- NEMedian3x3 median{};
- CLGaussian5x5 gauss{};
- std::string output_filename{};
-};
-
-/** Main program for neon/cl scale median gaussian test
- *
- * @param[in] argc Number of arguments
- * @param[in] argv Arguments ( [optional] Path to PPM image to process )
- */
-int main(int argc, char **argv)
-{
- return utils::run_example<NEONCLScaleMedianGaussianExample>(argc, argv);
-}