Ask Your Question

Nandika's profile - activity

2020-02-22 06:20:02 -0600 received badge  Famous Question (source)
2019-05-23 23:08:11 -0600 received badge  Notable Question (source)
2018-08-06 04:18:14 -0600 received badge  Popular Question (source)
2018-02-04 23:37:40 -0600 received badge  Famous Question (source)
2016-11-04 02:28:34 -0600 received badge  Enthusiast
2016-10-28 13:36:35 -0600 commented answer Error at template matching in Python

I converted both source and template to gray before.But, got same Error.. Now Its working...But, My template is not a gray.

So,This template and source is not same.

OpenCV docs said,

''image – Image where the search is running. It must be 8-bit or 32-bit floating-point.

templ – Searched template. It must be not greater than the source image and have the same data type.''

What type of data type mentioned in that docs?

2016-10-28 13:27:49 -0600 received badge  Scholar (source)
2016-10-28 09:22:14 -0600 commented question Error at template matching in Python

code is added This question also in Stackoverflow http://stackoverflow.com/questions/40...

2016-10-28 09:20:31 -0600 received badge  Editor (source)
2016-10-27 14:04:15 -0600 asked a question Error at template matching in Python

I'm trying to template matching using my web cam.I used web cam feed as source and used a template as small image that taken from web cam. Both template and source have same bit depth.(uint8). same data type of source(left) and template(right)

I'm using OpenCV3.0 with python 2.7 in VS 2013 IDE I got this error:

C:\builds\master_PackSlaveAddon-win32-vc12-static\opencv\modules\imgproc\src\templmatch.cpp:1062: error: (-215) (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 in function cv::matchTemplate

Code:

import cv2
import numpy as np

cam=cv2.VideoCapture(1)
template = cv2.imread("C:/Users/Nandika/Desktop/ttt.jpg",0)
w, h = template.shape[::-1]

method=cv2.TM_CCOEFF_NORMED

    while 1:
        _,img=cam.read()
        res = cv2.matchTemplate(img,template,method)
        min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res)

        # If the method is TM_SQDIFF or TM_SQDIFF_NORMED, take minimum
        if method in [cv2.TM_SQDIFF, cv2.TM_SQDIFF_NORMED]:
            top_left = min_loc
        else:
            top_left = max_loc
        bottom_right = (top_left[0] + w, top_left[1] + h)

        cv2.rectangle(img,top_left, bottom_right, 255, 2)

        cv2.imshow('img',img)


        if cv2.waitKey(1) & 0xFF == ord('q'):
            cv2.destroyAllWindow

Give me a solution

Thank in advance

2016-08-25 08:00:47 -0600 received badge  Popular Question (source)
2016-08-25 08:00:47 -0600 received badge  Notable Question (source)
2016-01-15 02:18:18 -0600 commented answer webcam capture problems

import numpy as np

import cv2

img = cv2.imread('foo.jpg')

height, width, channels = img.shape

print height, width, channels

 600 800 3
2015-12-29 09:31:37 -0600 commented question OpenCV 3.1.0 on python 3.5.1 with windows 7 64bit
2015-12-29 09:29:27 -0600 commented question OpenCV 3.1.0 on python 3.5.1 with windows 7 64bit

how to build opencv from src?

2015-12-29 09:19:16 -0600 received badge  Supporter (source)
2015-12-29 09:17:23 -0600 asked a question OpenCV 3.1.0 on python 3.5.1 with windows 7 64bit

Hello,

My OS is windows 7 64bit. Python version 3.5.1 OpenCV version 3.1.0

I use VisualEtudio 2013 as IDE. First,I installed Visual Studio and then installed python.then I used PTVS(Python Tools For Visual Studio). python is working properly with VisualStudio.But,I cant use OpenCV in python. When I tried to run a code, following error is given from VisualStudio.

image description

please help me to solve this problem and give me a suitable numpy link.

Thank in advance