Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unwanted Horizontal Lines Appears when using cv2.putText() #37

Closed
DEKHTIARJonathan opened this issue May 31, 2017 · 5 comments
Closed

Comments

@DEKHTIARJonathan
Copy link
Contributor

System information (version)
  • OpenCV => opencv-python==3.2.0.7
  • Operating System / Platform => Windows 10 64 Bit
  • Python 3.5.3 and installed with PIP with a virtualenv
Detailed description

I use the following dummy_code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, cv2, time
import numpy as np

video_capture = cv2.VideoCapture(0)

h_offset  = 150
font      = cv2.FONT_HERSHEY_SIMPLEX
fontScale = 0.5
fontColor = (0, 255, 0)
thickness = 2

while True:
    
    start    = time.time()
    v_offset = 50 
    
    # Capture frame-by-frame
    ret, frame = video_capture.read()
    
    print("\n####################\n")
    
    for _ in range(5):
    
        printed_txt = "DOG" + " => " +str(round(25.3 ,1))+"%"
        cv2.putText(frame, printed_txt, (h_offset, v_offset), font, fontScale, fontColor, thickness)
        
        v_offset += 50
        
        print(printed_txt)

    cv2.imshow('Video', frame)

    key = cv2.waitKey(1)
    if key & 0xFF == ord('q'):
        break
    elif key & 0xFF == ord(' '):
        #raw_input("Press any key to stop pause")
        cv2.waitKey(0)       

    print("\nframe_rate: %2.2f images/sec" % (1 / (time.time() - start)))

# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()

Which leads to this screen :
image

Could anyone tell me why am I having these horizontal lines and how to remove them ?

Firstly posted here : opencv/opencv#8824

Thanks a lot dear friends

@skvark
Copy link
Member

skvark commented May 31, 2017

3.2.0.7 uses OpenCV 3.2.0 release which was published in December 2016. Those lines you are having are a bug in that version. The bug was fixed in opencv/opencv#7959 during this year. There has not been a new OpenCV release yet, and I'm not sure if I'm willing to patch single bugs in this repo. Bumping the release of this package to some unknown and untested commit in the OpenCV repo is also a bit risky and might introduce new bugs.

@DEKHTIARJonathan
Copy link
Contributor Author

It is definetely up to you and I don't want to influence on your decision process.
However, the issue seems to be induce by ininitialised variables in OpenCV and the fix have been merged and have pass the CI tests ... So the fix will be in the next release. You can decide to fix this bug, which appear everytime OpenCV try to draw a line / write text. Or you can decide to wait for next release ;)

Have a good day mate and thanks for the help,

Jonathan

@skvark
Copy link
Member

skvark commented May 31, 2017

I'm going to wait for the next release. I hope that the OpenCV guys get some minor bug fix release (3.2.x) out at some point. Thanks for the report, I'll follow the situation.

@DEKHTIARJonathan
Copy link
Contributor Author

No problem, I came back to opencv-python==3.1.0.5, for now it solves this problem ;)
Waiting for the next release.

Thanks a lot,

Jonathan

@skvark
Copy link
Member

skvark commented Aug 12, 2017

This bug should be now fixed since the latest release matches now OpenCV 3.3.0. The builds should be available in PyPI during the next ~5 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants