opencv3.0

opencv blend (overlay) two image with different channels

浪子不回头ぞ 提交于 2019-11-29 13:09:36
I want to overlay two images (maybe different format (channels) with opencv. Originally I use addWeighted, however, it fails on two images with different channels. Is there any way in opencv that can handle this case? Thanks No , there is no API in OpenCV that offers this feature nativelly. On the other hand, there's nothing stopping you from writing your own code to do that. A few weeks ago a made some changes to a function I saw somewhere else on the Internet to be able to: Pass two input images: the background as BGR and the foreground as BGRA ; Blend them together according to a simple

Shape Transformers and Interfaces OpenCV3.0

一笑奈何 提交于 2019-11-29 12:43:33
I was trying to make use of the new Shape Transformers and Interfaces of OpenCV3.0. Unfortunately it doesn't work as expected. To ensure not making any fancy warps and getting strange results cause of that reason I initialized a transformation where nothing at all should happen. But output of the transformation for a testpoint is always [0,0] and the warped image is always completley gray. Any suggestions what could be wrong are welcome. int main(void){ Mat img1 = imread("C:\\opencv\\sources\\samples\\data\\graf1.png", IMREAD_GRAYSCALE); std::vector<cv::Point2f> points1, testpoints; vector

OpenCV: how to create .vec file to use with opencv_traincascade

﹥>﹥吖頭↗ 提交于 2019-11-29 12:00:51
As I explained in my previous post here , I am trying to generate some cascade.xml files to recognize euro coins to be used in my iOS app. Anyway, I am founding many difficulties in understanding how to generate a .vec file to give as input to opencv_traincascade . This because I heard many dissenting views: someone told me that vector file must include only positive images containing only the object to recognize; someone else instead (and also as read in my tutorials) said that vector file must include "samples" images, in other words random backgrounds to which the object to recognize has

Fastest way to apply color matrix to RGB image using OpenCV 3.0?

风流意气都作罢 提交于 2019-11-29 07:33:49
I have a color image represented as an OpenCV Mat object (C++, image type CV_32FC3). I have a color correction matrix that I want to apply to each pixel of the RGB color image (or BGR using OpenCV convention, doesn't matter here). The color correction matrix is 3x3. I could easily iterate over the pixels and create a vector v (3x1) representing RGB, and then compute M*v, but this would be too slow for my real-time video application. The cv::cvtColor function is fast, but does not seem to allow for custom color transformations. http://docs.opencv.org/2.4/modules/imgproc/doc/miscellaneous

Is cv2.cv missing in OpenCV 3.0?

ぃ、小莉子 提交于 2019-11-29 06:56:52
I've just installed OpenCV 3 on Win7 for using with Python 2.7. I've copied cv2.pyd to /DLLs. Unfortunately many examples I've tried, don't work, because cv2.cv seems to be missing in OpenCV3 Is there a replacement for it? Is there a table of new constant-names used to be declared in cv2.cv? Many thanks! yes, the deprecated cv2.cv was removed in opencv3.0 something similar to: import cv2 help(cv2) will give you a (looong) list of the api's content. To get old examples to work, you need to create/edit a file cv.py in site-packages with the following single line of text: import cv2 as cv Its not

compatibility issue with contourArea in openCV 3

谁都会走 提交于 2019-11-29 05:35:12
I am trying to do a simple area calculation of contours I get from findContours. My openCv version is 3.1.0 My code is: cc = cv2.findContours(im_bw.copy(), cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) cv2.contourArea(cc[0]) error: 'C:\\builds\\master_PackSlaveAddon-win32-vc12-static\\opencv\\modules\\imgproc\\src\\shapedescr.cp...: error: (-215) npoints >= 0 && (depth == CV_32F || depth == CV_32S) in function cv::contourArea\n' Cant seem to solve it, I have a feeling its just typecasting altough I expect the findContours result to match the type of contourArea Thanks :) EDIT: turns out I need to

How can I change the device on wich OpenCL-code will be executed with Umat in OpenCV?

邮差的信 提交于 2019-11-29 05:22:33
As known, OpenCV 3.0 supports new class cv::Umat which provides Transparent API (TAPI) to use OpenCL automaticaly if it can: http://code.opencv.org/projects/opencv/wiki/Opencv3#tapi There are two indtroductions to the cv::Umat and TAPI: Intel: https://software.intel.com/en-us/articles/opencv-30-architecture-guide-for-intel-inde-opencv AMD: http://developer.amd.com/community/blog/2014/10/15/opencv-3-0-transparent-api-opencl-acceleration/ But if I have: Intel CPU Core i5 (Haswell) 4xCores (OpenCL Intel CPUs with SSE 4.1, SSE 4.2 or AVX support ) Intel Integrated HD Graphics which supports OpenCL

AttributeError: 'module' object has no attribute 'ORB'

蓝咒 提交于 2019-11-28 21:21:07
when I run my python code import numpy as np import cv2 import matplotlib.pyplot as plt img1 = cv2.imread('/home/shar/home.jpg',0) # queryImage img2 = cv2.imread('/home/shar/home2.jpg',0) # trainImage # Initiate SIFT detector orb = cv2.ORB() # find the keypoints and descriptors with SIFT kp1, des1 = orb.detectAndCompute(img1,None) kp2, des2 = orb.detectAndCompute(img2,None) # create BFMatcher object bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True) # Match descriptors. matches = bf.match(des1,des2) # Sort them in the order of their distance. matches = sorted(matches, key = lambda x:x

TypeError: Required argument 'outImg' (pos 6) not found

做~自己de王妃 提交于 2019-11-28 19:09:20
When I run my python code import numpy as np import cv2 import matplotlib.pyplot as plt img1 = cv2.imread('/home/shar/home.jpg',0) # queryImage img2 = cv2.imread('/home/shar/home2.jpg',0) # trainImage # Initiate SIFT detector sift = cv2.xfeatures2d.SIFT_create() # find the keypoints and descriptors with SIFT kp1, des1 = sift.detectAndCompute(img1,None) kp2, des2 = sift.detectAndCompute(img2,None) # BFMatcher with default params bf = cv2.BFMatcher() matches = bf.knnMatch(des1,des2, k=2) # Apply ratio test good = [] for m,n in matches: if m.distance < 0.75*n.distance: good.append([m]) # cv2

Opencv 3 SVM training

◇◆丶佛笑我妖孽 提交于 2019-11-28 18:57:45
As you may know, many things changed in OpenCV 3 (in comparision to the openCV2 or the old first version). In the old days, to train SVM one would use: CvSVMParams params; params.svm_type = CvSVM::C_SVC; params.kernel_type = CvSVM::POLY; params.gamma = 3; CvSVM svm; svm.train(training_mat, labels, Mat(), Mat(), params); In the third version of API, there is no CvSVMParams nor CvSVM . Surprisingly, there is a documentation page about SVM , but it tells everything, but not how to really use it (at least I cannot make it out). Moreover, it looks like no one in the Internet uses SVM from OpenCV's