vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e

This commit is contained in:
Gitea Mirror Bot
2026-08-22 00:11:13 +08:00
commit 12022378a3
3872 changed files with 2513409 additions and 0 deletions
@@ -0,0 +1,60 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include <iostream>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/cann.hpp>
#include <opencv2/cann_interface.hpp>
int main(int argc, char* argv[])
{
cv::CommandLineParser parser(argc, argv,
"{@input|puppy.png|path to input image}"
"{@output|output.png|path to output image}"
"{help||show help}");
parser.about("This is a sample for image processing with Ascend NPU. \n");
if (argc != 3 || parser.has("help"))
{
parser.printMessage();
return 0;
}
std::string imagePath = parser.get<std::string>(0);
std::string outputPath = parser.get<std::string>(1);
// read input image and generate guass noise
//! [input_noise]
cv::Mat img = cv::imread(imagePath);
// Generate gauss noise that will be added into the input image
cv::Mat gaussNoise(img.rows, img.cols, img.type());
cv::RNG rng;
rng.fill(gaussNoise, cv::RNG::NORMAL, 0, 25);
//! [input_noise]
// setup cann
//! [setup]
cv::cann::initAcl();
cv::cann::setDevice(0);
//! [setup]
//! [image-process]
cv::Mat output;
// add gauss noise to the image
cv::cann::add(img, gaussNoise, output);
// rotate the image with a certain mode (0, 1 and 2, correspond to rotation of 90, 180 and 270
// degrees clockwise respectively)
cv::cann::rotate(output, output, 0);
// flip the image with a certain mode (0, positive and negative number, correspond to flipping
// around the x-axis, y-axis and both axes respectively)
cv::cann::flip(output, output, 0);
//! [image-process]
cv::imwrite(outputPath, output);
//! [tear-down-cann]
cv::cann::resetDevice();
cv::cann::finalizeAcl();
//! [tear-down-cann]
return 0;
}
@@ -0,0 +1,42 @@
# This file is part of OpenCV project.
# It is subject to the license terms in the LICENSE file found in the top-level directory
# of this distribution and at http://opencv.org/license.html.
import numpy as np
import cv2
import argparse
parser = argparse.ArgumentParser(description='This is a sample for image processing with Ascend NPU.')
parser.add_argument('image', help='path to input image')
parser.add_argument('output', help='path to output image')
args = parser.parse_args()
# read input image and generate guass noise
#! [input_noise]
img = cv2.imread(args.image)
# Generate gauss noise that will be added into the input image
gaussNoise = np.random.normal(0, 25,(img.shape[0], img.shape[1], img.shape[2])).astype(img.dtype)
#! [input_noise]
# setup cann
#! [setup]
cv2.cann.initAcl()
cv2.cann.setDevice(0)
#! [setup]
#! [image-process]
# add gauss noise to the image
output = cv2.cann.add(img, gaussNoise)
# rotate the image with a certain mode (0, 1 and 2, correspond to rotation of 90, 180
# and 270 degrees clockwise respectively)
output = cv2.cann.rotate(output, 0)
# flip the image with a certain mode (0, positive and negative number, correspond to flipping
# around the x-axis, y-axis and both axes respectively)
output = cv2.cann.flip(output, 0)
#! [image-process]
cv2.imwrite(args.output, output)
#! [tear-down-cann]
cv2.cann.finalizeAcl()
#! [tear-down-cann]