Ask Your Question

rrr's profile - activity

2016-11-23 10:59:55 -0600 asked a question What is the problem in the code given below? why is it not able to detect all the templates and their right coordinates ?

import cv2 import numpy as np

grid_line_x=7 grid_line_y=7

m=600/(grid_line_x-1) n=600/(grid_line_y-1)

grid_map=[[0 for i in range(grid_line_x-1)]for j in range(grid_line_y-1)]

templates = ['plus.jpg','6.jpg','5.jpg','4,jpg','3.jpg','2,jpg','1.jpg','8.jpg','9.jpg','7.jpg','5.jpg']

numbers = ['0','2','3','4','5','6','7','8','9','+','-']

a = 2

img = cv2.imread('demo.jpg') img1 = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

for temp in templates: loc=0 template = cv2.imread(temp,0) w,h = template.shape[::-1] method =eval('cv2.TM_CCOEFF_NORMED') res = cv2.matchTemplate(img1,template,method) threshold = 0.6 loc = np.where( res >=threshold) for pt in zip(*loc[::-1]): cv2.rectangle(img,pt,(pt[0]+w,pt[1]+h),(0,0,255),2) print pt[0]/100 print pt[1]/100 #i1 = pt[0]/100 #j1 = pt[1]/100 #grid_map[i1][j1] = numbers[a] #a=a+1


print grid_map

cv2.waitKey(0) cv2.destroyAllWindows() //here the image demo.jpg contains a grid having dimension of 6*6 and having numbers from 0 to 9 .

2016-11-23 10:02:54 -0600 commented question how to extract the coordinates of contour in an image ?

Actually ,i want to detect the numbers in the image of the 6*6 grid by matching the templates of individual numbers, on the grid and then storing the detected numbers ,in another grid at the same position.I am getting a problem in extracting the location of the detected images.Please suggest me some method to do so.

2016-11-22 22:30:00 -0600 received badge  Editor (source)
2016-11-22 22:26:34 -0600 asked a question how to extract the coordinates of contour in an image ?

I am unable to trace the coordinates of the contour of the detected image.kindly suggest me some means by which i can do it or the code(in python) which can solve my problem.

2016-11-22 15:53:09 -0600 commented answer How to crop digits automatically in sequence for recognition?

Can u please write the above code in python?