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

opencv not terminating in shell or in jupyter notebook after inshow display image #532

Open
danishkhangithub opened this issue Aug 28, 2021 · 8 comments

Comments

@danishkhangithub
Copy link

danishkhangithub commented Aug 28, 2021

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.

@asmorkalov
Copy link
Collaborator

Possibly related: opencv/opencv#20597

@asmorkalov
Copy link
Collaborator

@danishkhangithub Thanks for the report.

  1. OpenCV handles window closing by (x) button in title incorrectly sometimes. Your code expects keyboard event in waitKey call.
  2. If 1. is not the case, please remove destroyAllWindows and try again.
  3. 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.

@asmorkalov asmorkalov added the bug label Aug 30, 2021
@asmorkalov asmorkalov self-assigned this Aug 30, 2021
@asmorkalov
Copy link
Collaborator

@danishkhangithub Have you had a chance to try the solution?

@danishkhangithub
Copy link
Author

danishkhangithub commented Sep 13, 2021 via email

@asmorkalov
Copy link
Collaborator

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.

@asmorkalov
Copy link
Collaborator

@danishkhangithub friendly reminder.

@asmorkalov
Copy link
Collaborator

Possibly related: opencv/opencv#20822

@vishisht-dubey
Copy link

vishisht-dubey commented Aug 17, 2022

Hey, I want to work on this issue
can u provide some more info??

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

No branches or pull requests

4 participants