opencv-python
opencv-python copied to clipboard
opencv not terminating in shell or in jupyter notebook after inshow display image
this is the code
# import libraries
import cv2
def face_detection():
# load some pre-trained data on face frontals from opencv (haar cascade algorithm)
trained_face_data = cv2.CascadeClassifier('./haarcascade_files/haarcascade_frontalface_default.xml')
# show an image to detect
cv2.namedWindow('output', cv2.WINDOW_AUTOSIZE)
img = cv2.imread('./images/rdj.jpg')
#ims = cv2.resize(img, (110, 540))
cv2.imshow('Face detector', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
print('completed')
if __name__ == '__main__':
face_detection()`
and the output is :
(scrpers) (base) danish-khan@danishkhan-Latitude-E6430:~/scrapers/machine_learning1/face_detection1$ python face_detection2.py
and this terminal is not ending even i forcefully want to ends it.
Possibly related: https://github.com/opencv/opencv/pull/20597
@danishkhangithub Thanks for the report.
- OpenCV handles window closing by (x) button in title incorrectly sometimes. Your code expects keyboard event in waitKey call.
- If 1. is not the case, please remove
destroyAllWindows
and try again. - Please take a look on related fix I posted. Most probably it fixes the issue. You have to rebuild OpenCV from sources and remove pip-managed packages for OpenCV to exclude conflicts. Please ensure that self-built OpenCV is used with
cv.getBuildInformation()
call.
@danishkhangithub Have you had a chance to try the solution?
yes it tried but still not work may this is the issue.
On Mon, Sep 13, 2021 at 11:29 AM Alexander Smorkalov < @.***> wrote:
@danishkhangithub https://github.com/danishkhangithub Have you had a chance to try the solution?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/opencv/opencv-python/issues/532#issuecomment-917881914, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJ45NZPDT5P7Z2QL3VBJSP3UBWK6LANCNFSM5C6WM72Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
could you give me more information to narrow down the search field:
- Your platform and how you install/build OpenCV
-
cv.getBuildInformation()
call output in the repro code. - Any details how you run the code: natively, over SSH, etc.
@danishkhangithub friendly reminder.
Possibly related: https://github.com/opencv/opencv/issues/20822
Hey, I want to work on this issue can u provide some more info??