<jupyter_start><jupyter_text>Opening Image Files with OpenCV OpenCV can open images in separate outside windows when you run a .py script. Keep in mind, at the moment, this often doesn't work with the iPython kernel in a Jupyter notebook for some complex reasons. (It's an open issue on the github page since solutions stil vary drastically depending on the user's OS).Let's explore how we can use Open CV to open files in a separate window. Typically you would run these sort of commands as a script! So we've also included a .py script that goes along with this lecture.<jupyter_code># MUST BE RUN AS .py SCRIPT IN ORDER TO WORK.
# PLEASE MAKE SURE TO WATCH THE FULL VIDEO FOR THE EXPLANATION TO THIS NOTEBOOK
# TO BE CLEAR: RUNNING THIS CELL WILL KILL THE KERNEL IF YOU USE JUPYTER DIRECTLY

import cv2

img = cv2.imread('../DATA/00-puppy.jpg',cv2.IMREAD_GRAYSCALE)
# Show the image with OpenCV
cv2.imshow('window_name',img)
# Wait for something on keyboard to be pressed to close window.
cv2.waitKey()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.057004830917874394, 'fraction_numerical': 0.00676328502415459, 'mean_word_length': 4.6, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '154065', 'license': 'MIT', 'n_tokens_mistral': 326, 'n_tokens_neox': 304, 'n_words': 158, 'path': '01-Image-Basics-with-OpenCV/01-Opening-Images-with-OpenCV.ipynb', 'repo_name': 'Ashleshk/Computer-Vision-with-Python-Udemy', 'size': '1035'}