Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

python - Extracted bounding image is very small

I have this code for detecting text on an image and bounding it by a green rectangle and extract each bounding text into a separate image, I have done this step but when it is generated and I try to open the image it is very small I cannot see it, I tried to apply resize but not works. please help me.

    img = cv2.imread(IMAGE_PATH)
    copy = img.copy()
    ROI_number = 0

for detection in result: 
    top_left = tuple([int(val) for val in detection[0][0]])
    bottom_right = tuple([int(val) for val in detection[0][2]])
    #text = detection[2]
    #font= cv2.FONT_HERSHEY_SIMPLEX
    img = cv2.rectangle(copy, top_left, bottom_right, (36,255,12), 2)
    ROI = copy[top_left, bottom_right]
    img2 = cv2.resize(ROI, dsize=(0,0), fx=5, fy=5)
    cv2.imwrite('ROI_{}.jpg'.format(ROI_number), ROI)
    #img = cv2.putText(img,text,(20,spacer), font, 1,(0,255,0),2,cv2.LINE_AA)
    ROI_number += 1
#plt.figure(figsize=(30,30))    
plt.imshow(img)
plt.show
cv2.imshow('copy', copy)
cv2.waitKey()
question from:https://stackoverflow.com/questions/65645627/extracted-bounding-image-is-very-small

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your image is small because it is truly small.

But every decent image viewer has zoom that can zoom in and magnify your small image.

Your resize code is not working because you put dim=(0,0) , however it should be None in order fx and fy to work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...