1. Customising Your Own Digital Clock with Python and Tkinter
- Python makes it easy to build a digital clock, making it a fun project for people who have some programming knowledge. Creating your own GUI apps allows you to adapt them to your needs, which is a terrific feature. All characteristics, including text font and background colour, are customizable. In this post, we’ll look at how to use Python’s time module and Tkinter library to create a digital clock.
- A well-liked Python library for developing GUI applications is Tkinter. It offers a selection of tools for creating user interfaces, such as windows, buttons, labels, and other elements. Most Python installations include Tkinter, which is simple to use and intuitive.
- The current time will be formatted as a string and shown in the digital clock using the strftime function.
- We must import the relevant modules before we can begin refer the code below.
import time
from tkinter import Label, Tk
app_window = Tk()
app_window.title("Digital Clock")
app_window.geometry("420x150")
app_window.resizable(1, 1)
text_font = ("Boulder", 68, 'bold')
background = "#f2e750"
foreground = "#363529"
border_width = 25
label = Label(app_window, font=text_font, bg=background, fg=foreground, bd=border_width)
label.grid(row=0, column=1)
def digital_clock():
time_live = time.strftime("%H:%M:%S")
label.config(text=time_live)
label.after(200, digital_clock)
digital_clock()
app_window.mainloop()
- In conclusion, creating a digital clock in Python using Tkinter is a fantastic project for programmers at the intermediate level. The clock we built in this post is only one illustration of what you can do with Python and Tkinter. You may modify your clock to add more functions and make it special to your needs with a little imagination and programming know-how.
- Tkinter is a flexible GUI toolkit that makes it simple to create graphical user interfaces that are interactive and intuitive. You can easily build cross-platform GUI apps thanks to Tkinter. I hope this lesson has clarified how to use Python and Tkinter to make a digital clock. Best you best in your upcoming projects!
2. Creating a Weight Conversion App with Tkinter in Python
- In this blog, we’ll use Tkinter to build a weight conversion tool. Users of the app will be able to convert between different weight units, such as grams, kilograms, milligrammes, and pounds.
- The standard weight conversion values include:
- 1 milligram = 0.001 gram
- 1 centigram = 0.01 gram
- 1 decigram = 0.1 gram
- 1 kilogram = 1000 grams
- 1 gram = 1000 milligrams
- 1 ton = 2000 pounds
- 1 pound = 16 ounces
- We’ll develop a function that takes input from the user and changes it to the chosen weight unit.
- For instance, if the user inputs a weight in grams, the function will, depending on what the user wants, convert it to pounds, kilograms, or milligrammes.
- To implement this capability, the user’s input will be collected from the entry box, converted to the relevant unit of weight, and then displayed in the text box.
- To sum up, building a weight conversion app with Tkinter is a simple procedure that entails building a fundamental GUI and adding functionality to convert the weight units. Users of this programme may quickly convert between different weight units, making it a helpful tool for individuals who frequently work with weights.
from tkinter import *
# Creating a GUI Window
window = Tk()
def from_kg():
gram = float(e2_value.get()) * 1000
pound = float(e2_value.get()) * 2.20462
ounce = float(e2_value.get()) * 35.274
t1.delete("1.0", END)
t1.insert(END, gram)
t2.delete("1.0", END)
t2.insert(END, pound)
t3.delete("1.0", END)
t3.insert(END, ounce)
e1 = Label(window, text="Input the weight in KG")
e2_value = StringVar()
e2 = Entry(window, textvariable=e2_value)
e3 = Label(window, text="Gram")
e4 = Label(window, text="Pound")
e5 = Label(window, text="Ounce")
t1 = Text(window, height=5, width=30)
t2 = Text(window, height=5, width=30)
t3 = Text(window, height=5, width=30)
b1 = Button(window, text="Convert", command=from_kg)
e1.grid(row=0, column=0)
e2.grid(row=0, column=1)
e3.grid(row=1, column=0)
e4.grid(row=1, column=1)
e5.grid(row=1, column=2)
t1.grid(row=2, column=0)
t2.grid(row=2, column=1)
t3.grid(row=2, column=2)
b1.grid(row=0, column=2)
window.mainloop()
- We urge you to learn more about Tkinter and see what other kinds of applications you may build using this framework. Tkinter is a great option for building GUIs in Python because of its straightforward syntax and cross-platform interoperability.
- Don’t be afraid to try new things and see what you can come up with. Once again, thanks for reading, and we hope you enjoy using Tkinter to create your weight conversion software.
3. Convert Roman Numbers to Decimals
- A common programming challenge that involves an understanding of operators, loops, conditional statements, and user-defined functions is converting Roman numerals to decimal values. In this post, we’ll look at how to use Python to translate Roman numerals into decimal values.
- Assigning decimal values to each letter of a Roman numeral is the first step in converting it to a decimal number. After giving each letter a decimal value, we may proceed to examine two adjacent letters at a time as we move from left to right along the Roman numeral string.
tallies = {
'I': 1,
'V': 5,
'X': 10,
'L': 50,
'C': 100,
'D': 500,
'M': 1000,
# specify more numerals if you wish
}
def roman_num_decimal(roman_num):
sum = 0
for i in range(len(roman_num) - 1):
left = roman_num[i]
right = roman_num[i + 1]
if tallies[left] < tallies[right]:
sum -= tallies[left]
else:
sum += tallies[left]
sum += tallies[roman_num[-1]]
return sum
print(roman_num_decimal('LXI'))
print(roman_num_decimal('M'))
- As a result, the intriguing programming challenge of converting Roman numerals to decimal numbers necessitates a thorough knowledge of the operators, loops, conditional statements, and user-defined functions in Python.
- You may easily change Roman numerals to decimal numbers by following the procedure described in this article, and you can develop more sophisticated apps that expand on this idea.
4. How to Write Python Code for an Alarm Clock?
- Getting up late and skipping essential meetings or appointments is getting old, right? Not to worry! We’ll show you how to use Python to make an alarm clock in this tutorial.
- We are going to use the Python DateTime module to make an alarm clock. It is simple to import this module into your programme because it is already installed in the Python programming language. The alarm sound will also be played using the Python playsound module.
The DateTime module must first be imported before we can use it to set the alarm’s time. Once the alarm is set, we can use a loop to repeatedly determine whether the current time corresponds to the alarm.
.
from datetime import datetime
from playsound import playsound
alarm_time = input("Enter the time of alarm to be set:HH:MM:SS\n")
alarm_hour = alarm_time[0:2]
alarm_minute = alarm_time[3:5]
alarm_seconds = alarm_time[6:8]
alarm_period = alarm_time[9:11].upper()
print(alarm_period)
print(f"Setting up alarm..at{alarm_hour}hr, {alarm_minute}min, {alarm_seconds}sec")
while True:
now = datetime.now()
current_hour = now.strftime("%I")
current_minute = now.strftime("%M")
current_seconds = now.strftime("%S")
current_period = now.strftime("%p")
# print(current_hour)
if alarm_period == current_period:
# print('insdie if')
if alarm_hour == current_hour:
# print(current_hour)
if alarm_minute == current_minute:
if alarm_seconds == current_seconds:
print("Wake Up!")
playsound('alarm.mp3')
break
# input format - 12:50:00 PM
- In conclusion, building an alarm clock in Python is an easy and enjoyable project that may help you manage your time effectively and never miss a meeting or appointment. You can design an alarm clock that is tailored to your requirements and tastes by following the instructions provided in this article. Set your alarm, get up on time, and start your day with a fresh perspective!
5. Calculator GUI with Python
We need to construct functions for each operation and use global variables to store input values and output results in order to build a calculator GUI in Python using the tkinter package. To make sure the calculator works properly, it is essential to handle exceptions like division by zero and invalid inputs. An advanced-level project that can help you hone your programming abilities is making a calculator GUI in Python.
The typical Python GUI (Graphical User Interface) module is called Tkinter. You don’t need to install it individually because Python already has it built in as a module. To design your GUI, the tkinter module offers a variety of widgets, including buttons, labels, textboxes, and more.
from tkinter import *
from tkinter import messagebox
import math
screen=Tk()
screen.title('My calculator')
screen.configure(background='red')
screen.maxsize(width=453,height=490)
screen.minsize(width=358,height=490)
screen.geometry('358x490')
def click(number):
global operator
operator+=str(number)
tex.set(operator)
def clear():
global operator
operator=' '
tex.set(operator)
def equal():
global operator
try:
result=eval(operator)
operator=str(result)
tex.set(operator)
except:
messagebox.showinfo('notification','Try again something is wrong',parent=screen)
def cmsin():
global operator
try:
result=math.sin(eval(tex.get()))
operator=str(result)
tex.set(operator)
except:
messagebox.showinfo('notification','Try again something is wrong',parent=screen)
def cmcos():
global operator
try:
result=math.cos(eval(tex.get()))
operator=str(result)
tex.set(operator)
except:
messagebox.showinfo('notification','Try again something is wrong',parent=screen)
def cmtan():
global operator
try:
result=math.tan(eval(tex.get()))
operator=str(result)
tex.set(operator)
except:
messagebox.showinfo('notification','Try again something is wrong',parent=screen)
def cmsqrt():
global operator
try:
result=math.sqrt(eval(tex.get()))
operator=str(result)
tex.set(operator)
except:
messagebox.showinfo('notification','Try again something is wrong',parent=screen)
def cmlog():
global operator
try:
result=math.log(eval(tex.get()))
operator=str(result)
tex.set(operator)
except:
messagebox.showinfo('notification','Try again something is wrong',parent=screen)
tex=StringVar()
operator=' '
entry1=Entry(screen,bg='orange',font=('arial',20,'italic bold'),bd='30',justify='right',textvariable=tex)
entry1.grid(row=0,columnspan=4)
btn7=Button(screen,text='7',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(7)
,activebackground='green',activeforeground='white',bg='powder blue')
btn7.grid(row=1,column=0)
btn8=Button(screen,text='8',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(8),
activebackground='green',activeforeground='white',bg='powder blue')
btn8.grid(row=1,column=1)
btn9=Button(screen,text='9',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(9),activebackground='green',activeforeground='white',bg='powder blue')
btn9.grid(row=1,column=2)
btnadd=Button(screen,text='+',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click('+'),activebackground='green',activeforeground='white',bg='powder blue')
btnadd.grid(row=1,column=3)
btn4=Button(screen,text='4',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(4),activebackground='green',activeforeground='white',bg='powder blue')
btn4.grid(row=2,column=0)
btn5=Button(screen,text='5',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(5),activebackground='green',activeforeground='white',bg='powder blue')
btn5.grid(row=2,column=1)
btn6=Button(screen,text='6',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(6),activebackground='green',activeforeground='white',bg='powder blue')
btn6.grid(row=2,column=2)
btnsub=Button(screen,text='-',font=('arial',20,'italic bold'),bd='8',padx=20,pady=16,command=lambda:click('-'),activebackground='green',activeforeground='white',bg='powder blue')
btnsub.grid(row=2,column=3)
btn1=Button(screen,text='1',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(1),activebackground='green',activeforeground='white',bg='powder blue')
btn1.grid(row=3,column=0)
btn2=Button(screen,text='2',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(2),activebackground='green',activeforeground='white',bg='powder blue')
btn2.grid(row=3,column=1)
btn3=Button(screen,text='3',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(3),activebackground='green',activeforeground='white',bg='powder blue')
btn3.grid(row=3,column=2)
btnmul=Button(screen,text='x',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click('*'),activebackground='green',activeforeground='white',bg='powder blue')
btnmul.grid(row=3,column=3)
btn0=Button(screen,text='0',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click(0),activebackground='green',activeforeground='white',bg='powder blue')
btn0.grid(row=4,column=0)
btnclear=Button(screen,text='c',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=clear,activebackground='green',activeforeground='white',bg='powder blue')
btnclear.grid(row=4,column=1)
btnequal=Button(screen,text='=',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=equal,activebackground='green',activeforeground='white',bg='powder blue')
btnequal.grid(row=4,column=2)
btndiv=Button(screen,text='/',font=('arial',20,'italic bold'),bd='8',padx=16,pady=16,command=lambda:click('/'),activebackground='green',activeforeground='white',bg='powder blue')
btndiv.grid(row=4,column=3)
#################Advanced calculations
btnsin=Button(screen,text='sin',font=('arial',15,'italic bold'),bd='8',padx=14,pady=21,command=cmsin,activebackground='green',activeforeground='white',bg='powder blue')
btnsin.grid(row=0,column=4)
btncos=Button(screen,text='cos',font=('arial',15,'italic bold'),bd='8',padx=16,pady=21,command=cmcos,activebackground='green',activeforeground='white',bg='powder blue')
btncos.grid(row=1,column=4)
btntan=Button(screen,text='tan',font=('arial',15,'italic bold'),bd='8',padx=16,pady=21,command=cmtan,activebackground='green',activeforeground='white',bg='powder blue')
btntan.grid(row=2,column=4)
btnsqrt=Button(screen,text='sqrt',font=('arial',15,'italic bold'),bd='8',padx=14,pady=21,command=cmsqrt,activebackground='green',activeforeground='white',bg='powder blue')
btnsqrt.grid(row=3,column=4)
btnlog=Button(screen,text='log',font=('arial',15,'italic bold'),bd='8',padx=18,pady=25,command=cmlog,activebackground='green',activeforeground='white',bg='powder blue')
btnlog.grid(row=4,column=4)
################### Binding
screen.mainloop()
- The fascinating and difficult project of using Python to build a calculator GUI can advance your Python programming abilities.
6. Create Amazing Graphics with Python
The amazing idea of turtle graphics makes it possible to design stunning visual displays in Python. The turtle module creates a virtual world where turtles can turn left or right, travel forward or backward, and draw lines of various colours while moving around on a 2-dimensional grid. With only a few lines of code, you can build intricate drawings and designs using the turtle module.
Although mastering the turtle module can be difficult, doing so is a great way to advance your Python programming abilities. You may make original and striking visuals by playing with various commands and techniques.
import turtle as tu
roo = tu.Turtle() # Turtle object
wn = tu.Screen() # Screen Object
wn.bgcolor("black") # Screen Bg color
wn.title("Fractal Tree Pattern")
roo.left(90) # moving the turtle 90 degrees towards left
roo.speed(2) # setting the speed of the turtle
def draw(l): # recursive function taking length 'l' as argument
if (l < 10):
return
else:
roo.pensize(2) # Setting Pensize
roo.pencolor("yellow") # Setting Pencolor as yellow
roo.forward(l) # moving turtle forward by 'l'
roo.left(30) # moving the turtle 30 degrees towards left
draw(3 * l / 4) # drawing a fractal on the left of the turtle object 'roo' with 3/4th of its length
roo.right(60) # moving the turtle 60 degrees towards right
draw(3 * l / 4) # drawing a fractal on the right of the turtle object 'roo' with 3/4th of its length
roo.left(30) # moving the turtle 30 degrees towards left
roo.pensize(2)
roo.backward(l) # returning the turtle back to its original psition
draw(20) # drawing 20 times
roo.right(90)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(2)
roo.pencolor("magenta") # magenta
roo.forward(l)
roo.left(30)
draw(3 * l / 4)
roo.right(60)
draw(3 * l / 4)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(20)
roo.left(270)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(2)
roo.pencolor("red") # red
roo.forward(l)
roo.left(30)
draw(3 * l / 4)
roo.right(60)
draw(3 * l / 4)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(20)
roo.right(90)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(2)
roo.pencolor('#FFF8DC') # white
roo.forward(l)
roo.left(30)
draw(3 * l / 4)
roo.right(60)
draw(3 * l / 4)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(20)
########################################################
def draw(l):
if (l < 10):
return
else:
roo.pensize(3)
roo.pencolor("lightgreen") # lightgreen
roo.forward(l)
roo.left(30)
draw(4 * l / 5)
roo.right(60)
draw(4 * l / 5)
roo.left(30)
roo.pensize(3)
roo.backward(l)
draw(40)
roo.right(90)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(3)
roo.pencolor("red") # red
roo.forward(l)
roo.left(30)
draw(4 * l / 5)
roo.right(60)
draw(4 * l / 5)
roo.left(30)
roo.pensize(3)
roo.backward(l)
draw(40)
roo.left(270)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(3)
roo.pencolor("yellow") # yellow
roo.forward(l)
roo.left(30)
draw(4 * l / 5)
roo.right(60)
draw(4 * l / 5)
roo.left(30)
roo.pensize(3)
roo.backward(l)
draw(40)
roo.right(90)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(3)
roo.pencolor('#FFF8DC') # white
roo.forward(l)
roo.left(30)
draw(4 * l / 5)
roo.right(60)
draw(4 * l / 5)
roo.left(30)
roo.pensize(3)
roo.backward(l)
draw(40)
########################################################
def draw(l):
if (l < 10):
return
else:
roo.pensize(2)
roo.pencolor("cyan") # cyan
roo.forward(l)
roo.left(30)
draw(6 * l / 7)
roo.right(60)
draw(6 * l / 7)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(60)
roo.right(90)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(2)
roo.pencolor("yellow") # yellow
roo.forward(l)
roo.left(30)
draw(6 * l / 7)
roo.right(60)
draw(6 * l / 7)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(60)
roo.left(270)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(2)
roo.pencolor("magenta") # magenta
roo.forward(l)
roo.left(30)
draw(6 * l / 7)
roo.right(60)
draw(6 * l / 7)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(60)
roo.right(90)
roo.speed(2000)
# recursion
def draw(l):
if (l < 10):
return
else:
roo.pensize(2)
roo.pencolor('#FFF8DC') # white
roo.forward(l)
roo.left(30)
draw(6 * l / 7)
roo.right(60)
draw(6 * l / 7)
roo.left(30)
roo.pensize(2)
roo.backward(l)
draw(60)
wn.exitonclick()
- With the interesting and sophisticated project Turtle Graphics, you may let your imagination run wild and discover the potential of Python programming.
- You may construct beautiful visual shows with the turtle module that will astound your friends and coworkers. In order to understand more about Turtle Graphics, make sure to read the official documentation and get to enjoying it right away!
7. Never Miss a Reminder: Creating Desktop Notifications with Python
- Python’s method for receiving desktop notifications. When we wish to keep track of our plans and objectives, desktop notifications can be very helpful. This post examined a straightforward Python desktop notification app creation technique.
- The Plyer library was used to create and distribute desktop notifications. The time library was also used to arrange the appearance of notifications at particular times.
- You may easily make a desktop notification app that meets your needs by using the procedures described in this article. A desktop notification software can be an effective tool for keeping you on track with your goals or for reminding you of essential activities or events.
- So why not try it out? Using only
import time
# pip install plyer
from plyer import notification
if __name__ == "__main__":
while True:
print('inside')
notification.notify(
title="ALERT!!!",
message="Take a break! It has been an hour!",
timeout=10
)
time.sleep(3)
8. Improving Your Text Accuracy with Spelling Correction in Python
- Spelling mistakes are frequent in written communication, and they can significantly affect the message that is being conveyed. Spelling correction is a common issue in natural language processing, and it has received a lot of attention in the machine learning community. Thankfully, the textblob module in Python offers a simple method for performing spelling correction.
- We’ll introduce the textblob library and show you how to use it to fix spelling mistakes in text data in this blog article.
Overview of the textblob library : For applications involving natural language processing, like sentiment analysis, part-of-speech tagging, and text translation, the textblob library for Python offers an easy-to-use API. It offers a high-level interface for working with text data and is built on top of the NLTK library.
The textblob library’s spelling check tool is one of its features. The library offers a spelling correction method that fixes typos in text data by combining statistical modelling and rule-based approaches.
from textblob import TextBlob
words = input('Enter words').split()
corrected_words = []
for i in words:
corrected_words.append(TextBlob(i))
print("All Words :", words)
print("Corrected Words are :")
for i in corrected_words:
print(i.correct(), end=" ")
9. Converting Videos to Audio with Pytube in Python
A Python module called Pytube makes it simple for programmers to download YouTube videos. We will examine how to utilise Pytube to convert movies to audio files in this article. You could prefer to listen to a video’s audio track only, for example, in which case converting videos to audio files can be helpful.
Before installing any project dependencies, we will import Pytube. Then, using the video’s URL, we will develop a function that will extract the audio track. The Pydub library will also be used to create an MP3 file from the retrieved audio.
Once the function has been developed, a graphical user interface (GUI) that allows users to input URLs and output converted audio files can be made. The labels, entry boxes, and buttons can be made using Tkinter, a Python library for building GUIs.
import os
import pytube
from pytube import YouTube
def main():
video_url = 'https://www.youtube.com/watch?v=W4sHmzMCo8s&ab_channel=JavedAli-Topic'
if os.name == 'nt':
path = os.getcwd() + '\\'
else:
path = os.getcwd() + '/'
name = pytube.extract.video_id(video_url)
print(name)
YouTube(video_url).streams.filter(only_audio=True).first().download(filename=name)
location = path + name + '.mkv'
print(location)
renametomp3 = path + name+ '.mp3'
print(renametomp3)
if os.name == 'nt':
print('Inside')
os.system('ren {0} {1}'.format(location, renametomp3))
else:
os.system('mv {0} {1}'.format(location, renametomp3))
if __name__ == '__main__':
main()
- In end, we can simply convert videos to audio files using Python’s Pytube and Pydub libraries. This procedure can be completed fast and effectively whether you wish to capture a video’s audio track or extract audio from a video. We can design a user-friendly GUI for this programme using Tkinter. Check it out for yourself to see how useful this programme is in different situations.
10. Python Tutorial on Using a Phone Camera
Have you ever considered the potential of using the camera on your phone for computer vision tasks? You can, indeed! I’ll demonstrate how to use the camera on your phone with Python for computer vision in this tutorial.
For individuals who intend to develop computer vision applications that will incorporate a smartphone camera as a component of their programme, using a phone camera with Python is quite helpful. Python is being used here on Windows 10. If you use Windows, don’t worry; just follow the instructions below. I hope this works for other OS systems as well.
- Python’s method for leveraging a phone camera.
- Start by using pip install opencv-python to install the OpenCV library in Python.
- On your cellphones, download and install the IP Webcam app.
- Make sure your phone and PC are linked to the same network after installing the IP Webcam app. Launch the server by running the app on your phone.
- Your camera will then start up and display an IP address at the bottom. In order to open your phone’s camera in our Python code, we must have the IP address.
import cv2
import numpy as np
url = "https://[2405:201:1017:e00e:da32:e3ff:fe6c:ccfb]:8080/video"
cp = cv2.VideoCapture(url)
while(True):
camera, frame = cp.read()
if frame is not None:
cv2.imshow("Frame", frame)
q = cv2.waitKey(1)
if q==ord("q"):
break
cv2.destroyAllWindows()
- In short, a phone camera can be a useful tool for computer vision applications when combined with Python. We can quickly and simply capture photos and videos from the phone’s camera and use them for various computer vision applications with the help of the OpenCV and numpy libraries.