opencv3.0

python opencv cv2 matchTemplate with transparency

风流意气都作罢 提交于 2019-11-30 05:34:14
问题 OpenCV 3.0.0 added the ability to specify a mask while performing templateMatch. When I specify a mask I get this error: error: (-215) (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 in function matchTemplateMask Template image (PNG with transparency): Source image: Code # read the template emoji with the alpha channel template = cv2.imread(imagePath, cv2.IMREAD_UNCHANGED) channels = cv2.split(template) zero_channel = np.zeros_like(channels[0]) mask = np.array

Python opencv sorting contours

佐手、 提交于 2019-11-30 02:04:08
I am following this question: How can I sort contours from left to right and top to bottom? to sort contours from left-to-right and top-to-bottom. However, my contours are found using this (OpenCV 3): im2, contours, hierarchy = cv2.findContours(threshold,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE) and they are formatted like this: array([[[ 1, 1]], [[ 1, 36]], [[63, 36]], [[64, 35]], [[88, 35]], [[89, 34]], [[94, 34]], [[94, 1]]], dtype=int32)] When I run the code max_width = max(contours, key=lambda r: r[0] + r[2])[0] max_height = max(contours, key=lambda r: r[3])[3] nearest = max_height * 1.4

How do I use SIFT in OpenCV 3.0 with c++?

荒凉一梦 提交于 2019-11-30 00:38:55
I have OpenCV 3.0, and I have compiled & installed it with the opencv_contrib module so that's not a problem. Unfortunately the examples from previous versions do not work with the current one, and so although this question has already been asked more than once I would like a more current example that I can actually work with. Even the official examples don't work in this version (feature detection works but not other feature examples) and they use SURF anyway. So, how do I use OpenCV SIFT on C++? I want to grab the keypoints in two images and match them, similar to this example , but even

Xcode 7 does not build project with c++ framework

假装没事ソ 提交于 2019-11-29 23:30:00
问题 I can't build project with a new version of the opencv 3.0.0 framework (version 2 did not have this problem). Xcode 7 does not compile c++ sources as c++. Here's the simplest setup that is not building: Download the 3.0.0 framework from here http://netix.dl.sourceforge.net/project/opencvlibrary/opencv-ios/3.0.0/opencv2.framework.zip Create the simplest ios project with Swift language. Drag-and-drop the framework to the project. Create the Objective-C++ source and headers and add them to the

BGR to HSV and back again

我怕爱的太早我们不能终老 提交于 2019-11-29 16:29:57
The documentation does not seem to explain what the expected range of the input is for an HSV->BGR conversion. Here is some example code where I am trying to get back the original BGR value after converting it to HSV. Does anyone know which scaling is expected? #include <iostream> #include <opencv2/opencv.hpp> cv::Vec3b HSVtoBGR(const cv::Vec3f& hsv) { cv::Vec3f hsvAdjusted = hsv; // If we use this directly, the output is (0,0,1) which is very wrong //hsvAdjusted[0] *= 360.; // If we do this to bring all of the values into the range (0,1), the output is (0,1,0), which is also very wrong // If

OpenCV resize fails on large image with “error: (-215) ssize.area() > 0 in function cv::resize”

僤鯓⒐⒋嵵緔 提交于 2019-11-29 16:12:32
问题 I'm using OpenCV 3.0.0 and Python 3.4.3 to process a very large RGB image (107162,79553,3). While I'm trying to resize it using the following code: import cv2 image = cv2.resize(img, (0,0), fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA) I had this error message coming up : "cv2.error: C:\opencv-3.0.0\source\modules\imgproc\src\imgwarp.cpp:3208: error: (-215) ssize.area() > 0 in function cv::resize" I'm certain there is image content in the image array because I can save them into small tiles

OpenCV: AttributeError: module 'cv2' has no attribute 'face'

五迷三道 提交于 2019-11-29 15:51:34
I am creating a face recognition system using Python and OpenCV on these versions: Python 3.6.2 :: Anaconda custom (64-bit) Anaconda 4.3.23 OpenCV 3.3.0 When I try to train the face recognizer: face_recognizer = cv2.face.createLBPHFaceRecognizer() I get this error: AttributeError: module 'cv2' has no attribute 'face' Update: I've tried to do this: pip install opencv_python‑3.3.0+contrib‑cp36‑cp36m‑win_amd64.whl Also: conda install -c menpo opencv3=3.3.0 And I still have the error. The Menpo project does not have an installer for OpenCV 3.3. The Menpo project is up to 3.1 on macOS and Windows,

OpenCV for OCR: How to compute thresholding levels for gray image OCR

我只是一个虾纸丫 提交于 2019-11-29 15:46:01
问题 I'm trying to prepare images for OCR, and so far here is what I've done using info from Extracting text OpenCV From the resulting image I use the contours that have been filtered to make a mask as follow: //this is the mask of all the text Mat maskF = Mat::zeros(rgb.rows, rgb.cols, CV_8UC1); // CV_FILLED fills the connected components found - CV_FILLED to fill drawContours(maskF, letters, -1, Scalar(255), CV_FILLED); cv::imwrite("noise2-Mask.png", maskF); the resulting img is promising:

openCV 3.0.0 cv::vector missing

懵懂的女人 提交于 2019-11-29 14:09:05
I'm upgrading from opencv 2.4.11 to 3.0.0 I have used cv::vector in my code <br> but now I get the error vector in not a member of 'cv' I will start using std::vector instead <br> however I can't find anywhere was it removed or just moved to another header file? In OpenCV prior to 3.0, you can see at the beginning of core.hpp that OpenCV is using std::vector internally: #ifndef __OPENCV_CORE_HPP__ #define __OPENCV_CORE_HPP__ ... #include <vector> ... /*! \namespace cv Namespace where all the C++ OpenCV functionality resides */ namespace cv { ... using std::vector; ... So you can access std:

OpenCV 3 Tracker won't work after reinitialization

淺唱寂寞╮ 提交于 2019-11-29 14:05:55
I have issue using OpenCV 3 tracking module for tracking. It behaves same, either I use interface class (cv::Tracker) or class with implementation (like cv::TrackerMedianFlow or cv::TrackerMIL, etc). Sample is a bit modified sample from OpenCV sample folder After correct creation Ptr<Tracker> tracker = Tracker::create( tracker_algorithm ); if ( tracker == NULL ) { std::cout << "***Error in the instantiation of the tracker...***\n"; return -1; } initialization works just fine if ( !tracker->init( frame, boundingBox ) ) { std::cout << "***Could not initialize tracker...***\n"; return -1; }