40

I am trying to implement a license plate recognition software using the ideas from http://iamabhik.wordpress.com/category/opencv/.

I implemented the plate location using opencv in python, using "import cv2". It works okay and now I need to copy the plate region to another image to do the segmentation of the characters and then the OCR part (maybe using a neural network).

I found the GetSubRect() function to copy or isolate part of the image but it does not appear to be available in python. Is there an alternative? The ROI functions do not seem to be implemented either.

Is there an up-to-date documentation of the python interface to opencv?

I compiled opencv from svn repository (revision 7239) on a Debian wheezy/sid environment.

Fell free to suggest alternative methods/ideas to solve this problem.

Thanks in advance.

4

3 に答える 3

69

cv.GetSubRect と ROI 関数はどちらも Python で使用できますが、古いimport cvモードまたはimport cv2.cv. つまり、cv2.cv.GetSubRect()またはcv2.cv.SetImageROIそれらに精通している場合は使用します。

一方、新しい cv2 では numpy の統合により、これらの関数を使用せずに ROI を設定するのは簡単です。

(x1,y1) と (x2,y2) が得られたプレートの 2 つの反対側の頂点である場合、単純に関数を使用します。

roi = gray[y1:y2, x1:x2]

それがあなたのイメージ ROI です。

だからあなたに合ったものを選んでください。

于 2012-01-31T18:37:51.907 に答える
7

例: 点が少なく、領域をコピーしたい場合

r = cv2.boundingRect(pts)
cv2.imwrite('roi.png', im[r[0]:r[0]+r[2], r[1]:r[1]+r[3]])
于 2012-06-12T14:39:28.920 に答える