openalpr / train-detector

Input files and scripts necessary to train the license plate detector.
GNU Affero General Public License v3.0
125 stars 166 forks source link

Problem to crop the image #26

Closed zhouhao27 closed 6 years ago

zhouhao27 commented 6 years ago

Got the following error messgae:

No module named cv

Any idea? Thanks.

zhouhao27 commented 6 years ago

After I change the script a bit:

import os
import sys
import json
import math
import cv2

It's ok to run. But I found a problem in:

moment = cv.Moments(points)

Then I change this to:

moment = cv2.moments(points)

I got this error:

TypeError: array is not a numpy array, neither a scalar

Apparently these two moments function are not the same.

Any idea?

zhouhao27 commented 6 years ago

My code:

points = np.array([(x1,y1), (x2,y2), (x3,y3), (x4,y4)])
moment = cv2.moments(points)
centerx = int(round(moment['m10']/moment['m00']))
centery = int(round(moment['m01']/moment['m00']))

Solved the problem.