Screen Recorder OpenCV Python With Source Code
The Screen Recorder OpenCV Python was developed using Python OpenCV, Python is a widely used general-purpose language. It allows performing a variety of tasks. One of them can be recording a video. It provides a module named pyautogui which can be used for the same. This module along with NumPy and OpenCV provides the way to manipulate and save the images (screenshot in this case).
A OpenCV Python Screen Recording enables you to create demonstration videos, record gaming achievements and create videos that can be shared online on social media. Many industrial softwares exist out there that can help you do that very easily though. In this Simple Project With Source Code, you will learn how to make your own simple screen recorder in Python that you can further extend to your own needs.
What is OpenCV?
OpenCV is short for Open Source Computer Vision. Intuitively by the name, it is an open-source Computer Vision and Machine Learning library. This library is capable of processing real-time image and video while also boasting analytical capabilities. It supports the Deep Learning frameworks.
In this Python OpenCV Project also includes a downloadable Python Project With Source Code for free, just find the downloadable source code below and click to start downloading.
By the way if you are new to python programming and you don’t know what would be the the Python IDE to use, I have here a list of Best Python IDE for Windows, Linux, Mac OS that will suit for you. I also have here How to Download and Install Latest Version of Python on Windows.
To start executing Screen Recorder OpenCV Python With Source Code, make sure that you have installed Python 3.9 and PyCharm in your computer.
Screen Recorder OpenCV Python With Source Code : Steps on how to run the project
Time needed: 5 minutes.
These are the steps on how to run Screen Recorder OpenCV Python With Source Code
- Step 1: Download the given source code below.
First, download the given source code below and unzip the source code.
- Step 2: Import the project to your PyCharm IDE.
Next, import the source code you’ve download to your PyCharm IDE.
- Step 3: Run the project.
last, run the project with the command “py main.py”
import cv2 import tkinter as tk import numpy as np import pyautogui from tkinter.filedialog import asksaveasfilename import time import sys
Complete Source Code
import cv2 import tkinter as tk import numpy as np import pyautogui from tkinter.filedialog import asksaveasfilename import time import sys def run(): # display screen resolution, get it from your OS settings SCREEN_SIZE = pyautogui.size() # define the codec fourcc = cv2.VideoWriter_fourcc(*"XVID") # create the video write object file_name = asksaveasfilename(confirmoverwrite=False,defaultextension='.avi') out = cv2.VideoWriter(file_name, fourcc, 20.0, (SCREEN_SIZE)) print("Recording Started...\n") odd=1 while True: odd+=1 # make a screenshot img = pyautogui.screenshot() # convert these pixels to a proper numpy array to work with OpenCV frame = np.array(img) # convert colors from BGR to RGB frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) if(odd==10): cv2.imshow("Recording...", frame) odd=1 # if the user clicks q, it exits if cv2.waitKey(1) == ord("q"): cv2.destroyAllWindows() break # write the frame out.write(frame) out.release() root.destroy() sys.exit(0) def screenshot(): root.destroy() print("Screen Shot...\n") time.sleep(1) myScreenshot = pyautogui.screenshot() file_name = asksaveasfilename(confirmoverwrite=False,defaultextension='.png') myScreenshot.save(file_name) sys.exit(0) root = tk.Tk() root.title("Screen Recorder") root.geometry("600x220") root.configure(background = '#e6e5e5') frame = tk.Frame(root,bg = '#e6e5e5',pady = 1, width =550, height = 50) frame.grid(row=0,column=0) frame.pack() label0 = tk.Label(frame,font=('Comic Sans MS',26,'bold'),text = " Screen Recorder ",bg= '#663300',fg='white',justify ="center") label0.pack(side=tk.TOP) button =tk.Button(frame, font=('arial', 20,'bold'), text="Start Recording",padx=2,pady=2, bg="green",fg = "white",command=run) button.pack(side=tk.TOP) button1 =tk.Button(frame, font=('arial', 20,'bold'), text="Take Screenshot",padx=2,pady=2, bg="orange",fg = "white",command=screenshot) button1.pack() root.mainloop()
Download Source Code below
Anyway, if you want to level up your programming knowledge, especially Python OpenCV, try this new article I’ve made for you Best OpenCV Projects With Source Code For Beginners 2021.
In this Python project was developed and designed using Python OpenCV, Screen recording enables you to create demonstration videos, record gaming achievements and create videos that can be shared online on social media. Many industrial softwares exist out there that can help you do that very easily though.
In this tutorial, you will learn how to make your own simple screen recorder in Python that you can further extend to your own needs. and this Python OpenCV Project also includes a downloadable Python Project With Source Code for free.
- Code For Game in Python: Python Game Projects With Source Code
- Best Python Projects With Source Code 2020 FREE DOWNLOAD
- How to Make a Point of Sale In Python With Source Code 2021
- Python Code For Food Ordering System | FREE DOWNLOAD | 2020
- Inventory Management System Project in Python With Source Code
If you have any questions or suggestions about Screen Recorder OpenCV Python With Source Code, please feel free to leave a comment below.