Commit 57648c2c authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #876 from alalek:fix_contrib_872

parents bd619c55 31d11378
......@@ -5,7 +5,6 @@ import os
import cv2
import numpy as np
from matplotlib import pyplot as plt
print('\ndetect_er_chars.py')
print(' A simple demo script using the Extremal Region Filter algorithm described in:')
......@@ -32,8 +31,8 @@ regions = cv2.text.detectRegions(gray,er1,er2)
#Visualization
rects = [cv2.boundingRect(p.reshape(-1, 1, 2)) for p in regions]
for rect in rects:
cv2.rectangle(img, rect[0:2], (rect[0]+rect[2],rect[1]+rect[3]), (0, 0, 255), 2)
img = img[:,:,::-1] #flip the colors dimension from BGR to RGB
plt.imshow(img)
plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis
plt.show()
cv2.rectangle(img, rect[0:2], (rect[0]+rect[2],rect[1]+rect[3]), (0, 0, 0), 2)
for rect in rects:
cv2.rectangle(img, rect[0:2], (rect[0]+rect[2],rect[1]+rect[3]), (255, 255, 255), 1)
cv2.imshow("Text detection result", img)
cv2.waitKey(0)
......@@ -32,7 +32,6 @@ int main(int argc, const char * argv[])
if (argc < 2) show_help_and_exit(argv[0]);
namedWindow("grouping",WINDOW_NORMAL);
Mat src = imread(argv[1]);
// Extract channels to be processed individually
......@@ -70,8 +69,8 @@ int main(int argc, const char * argv[])
imshow("grouping",src);
cout << "Done!" << endl << endl;
cout << "Press 'e' to show the extracted Extremal Regions, any other key to exit." << endl << endl;
if( waitKey (-1) == 101)
cout << "Press 'space' to show the extracted Extremal Regions, any other key to exit." << endl << endl;
if ((waitKey()&0xff) == ' ')
er_show(channels,regions);
// memory clean-up
......
......@@ -5,7 +5,6 @@ import os
import cv2
import numpy as np
from matplotlib import pyplot as plt
print('\ntextdetection.py')
print(' A demo script of the Extremal Region Filter algorithm described in:')
......@@ -50,11 +49,10 @@ for channel in channels:
#Visualization
for r in range(0,np.shape(rects)[0]):
rect = rects[r]
cv2.rectangle(vis, (rect[0],rect[1]), (rect[0]+rect[2],rect[1]+rect[3]), (0, 255, 255), 2)
cv2.rectangle(vis, (rect[0],rect[1]), (rect[0]+rect[2],rect[1]+rect[3]), (0, 0, 0), 2)
cv2.rectangle(vis, (rect[0],rect[1]), (rect[0]+rect[2],rect[1]+rect[3]), (255, 255, 255), 1)
#Visualization
vis = vis[:,:,::-1] #flip the colors dimension from BGR to RGB
plt.imshow(vis)
plt.xticks([]), plt.yticks([]) # to hide tick values on X and Y axis
plt.show()
cv2.imshow("Text detection result", vis)
cv2.waitKey(0)
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment