In this post, we are going to see how to detect and track movements(simply motion detection and tracking) using the OpenCV module. At first, you need to install the OpenCV-python module, to install the module just open your command prompt and type, pip install OpenCV-python Then hit enter, it will install the module automatically. After installing the module, just import the module and write the basic code to read the video. # import the opencv module import cv2 # capturing video capture = cv2.VideoCapture( "videos/input.mp4" ) After that, we have to get the two frames from the video or webcam and find the difference between the two frames, which is nothing but if there is a movement that occurs between the frames there might be a difference. So, here we are trying to get the difference using the cv2.absdiff() function in the OpenCV module and this method takes two parameters which are the two frames. # find difference between two frames diff = cv2.absdiff(img_1 , img_2) T...
Basically, the hand tracking is based on the 21 landmarks in 3D with multi-hand support, based on high-performance palm detection and hand landmark model. The 21 hand landmarks will be like, And, The output will be like this, Packages to install : pip install opencv-python. pip install mediapipe. Program : # Hand Tracking with python import cv2 import mediapipe as mp import time # Capturing video from the web cam video = cv2.VideoCapture( 0 ) # Creating objects for hands mpHands = mp.solutions.hands hands = mpHands.Hands() previousTime = 0 currentTime = 0 while True : success , img = video.read() # Converting BGR image to RGB image RGBimg = cv2.cvtColor(img , cv2.COLOR_BGR2RGB) # Getting landmark points and storing in multiHandLandmarks variable result = hands.process(RGBimg) multiHandLandmarks = result.multi_hand_landmarks # This 'if' block will run when it's having the handlandmark points if multiHandLandmarks...
In this post, we are going to see one of the stack application's implementations which is a parenthesis checker and also the stack has several other applications like 🎯 R everse a string, 🎯 U ndo mechanism in editors, 🎯 R ecursion, 🎯 E xpression conversion, and so on. Here, I am using the 'queue' module to implement the stack in python. You can implement the stack without using the 'queue' module and you can check out here x Code😃 : I hope it will help you😊