<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dharshaan on Medium]]></title>
        <description><![CDATA[Stories by Dharshaan on Medium]]></description>
        <link>https://medium.com/@dharshaan2004?source=rss-c447a6ff30a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pXorhtZ8lobISZLFHG2ghw.jpeg</url>
            <title>Stories by Dharshaan on Medium</title>
            <link>https://medium.com/@dharshaan2004?source=rss-c447a6ff30a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 01:01:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dharshaan2004/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Hand Tracking 30 FPS using OpenCV]]></title>
            <link>https://medium.com/@dharshaan2004/hand-tracking-30-fps-using-opencv-eb2866d0d343?source=rss-c447a6ff30a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb2866d0d343</guid>
            <dc:creator><![CDATA[Dharshaan]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 06:56:03 GMT</pubDate>
            <atom:updated>2024-08-02T07:05:05.727Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Computer Vision:</strong></p><p>When we need to recognize what is represented in an image.</p><p><strong>Hand Tracking:</strong></p><p>It is a computer vision application that uses algorithms to detect and track human hand movements and gestures in real time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*VD5B5z2YZ8kgP3VDAMjCSw.png" /></figure><p><strong>Hand Landmarks:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_zu_EYpF3SEBhzpWRP2OAQ.png" /></figure><p><strong>Steps to Create a Hand Tracking Module:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*XpbJIwHRccebaTuQNw9Y3g.png" /></figure><p><strong>Find Hands:</strong></p><p>1.Converts the input image from BGR to RGB.<br>2.Detects hands in the image using Media pipe’s Hands model.<br>3.Optionally draws the detected hand landmarks and connections on the image.<br>4.Returns the processed image and the detection results.</p><p><strong>Find Position:</strong></p><p>1.Checks if there are any detected hand landmarks.<br>2.Retrieves the dimensions of the input image.<br>3.Iterates through the landmarks of the first detected hand.<br>4.Converts normalized coordinates of landmarks to pixel coordinates.<br>5.Appends the pixel coordinates to a list.<br>6.Optionally draws circles at the landmark positions on the image.<br>7.Returns the list of pixel coordinates.</p><p><strong>Program:</strong></p><p>import cv2<br>import mediapipe as mp<br>import time</p><p>class HandDetector:<br> def __init__(self, mode=False, maxHands=2, detectionCon=0.5, trackCon=0.5):<br> self.hands = mp.solutions.hands.Hands(<br> static_image_mode=mode,<br> max_num_hands=maxHands,<br> min_detection_confidence=detectionCon,<br> min_tracking_confidence=trackCon<br> )<br> self.mpDraw = mp.solutions.drawing_utils</p><p>def findHands(self, img, draw=True):<br> results = self.hands.process(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))<br> if draw and results.multi_hand_landmarks:<br> for handLms in results.multi_hand_landmarks:<br> self.mpDraw.draw_landmarks(img, handLms, mp.solutions.hands.HAND_CONNECTIONS)<br> return img, results</p><p>def findPosition(self, img, results, draw=True):<br> lmList = []<br> if results.multi_hand_landmarks:<br> h, w, _ = img.shape<br> for lm in results.multi_hand_landmarks[0].landmark:<br> cx, cy = int(lm.x * w), int(lm.y * h)<br> lmList.append([cx, cy])<br> if draw:<br> cv2.circle(img, (cx, cy), 5, (255, 0, 255), cv2.FILLED)<br> return lmList</p><p>def main():<br> pTime = 0<br> cap = cv2.VideoCapture(0)<br> detector = HandDetector()<br> while True:<br> success, img = cap.read()<br> if not success:<br> break<br> img, results = detector.findHands(img)<br> lmList = detector.findPosition(img, results)<br> if lmList:<br> print(lmList[4])</p><p>fps = 1 / (time.time() — pTime)<br> pTime = time.time()<br> cv2.putText(img, f’FPS: {int(fps)}’, (10, 70), cv2.FONT_HERSHEY_PLAIN, 3, (255, 0, 255), 3)<br> cv2.imshow(“Image”, img)<br> if cv2.waitKey(1) &amp; 0xFF == ord(‘q’):<br> break</p><p>cap.release()<br> cv2.destroyAllWindows()</p><p>if __name__ == “__main__”:<br> main()</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb2866d0d343" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Own Alexa]]></title>
            <link>https://medium.com/@dharshaan2004/building-own-alexa-96f20723501b?source=rss-c447a6ff30a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/96f20723501b</guid>
            <dc:creator><![CDATA[Dharshaan]]></dc:creator>
            <pubDate>Thu, 11 Jul 2024 11:56:39 GMT</pubDate>
            <atom:updated>2024-07-11T11:56:39.032Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Notice The Difference Differently</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z3vx1oHiKGFZYN06OrlPQQ.png" /></figure><p><strong>What is AI?</strong></p><p>Artificial intelligence is the simulation of human intelligence processes by machines, especially computer systems</p><p><strong>Types:</strong></p><ul><li>Narrow AI or artificial narrow intelligence (ANI)</li><li>General AI or artificial general intelligence (AGI)</li><li>Super AI or artificial superintelligence (ASI)</li></ul><p><strong>What is NLP?</strong></p><p>Natural language processing (NLP) is a machine learning technology that gives computers the ability to interpret, manipulate, and comprehend human language</p><p><strong>Steps for Alexa:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TgcBxKx9PMGrEqy5A2H0Xg.png" /></figure><p><strong>Libraries:</strong></p><p>1.speech_recognition</p><p>2.pyttsx3</p><p>3.pywhatkit</p><p>4.datetime</p><p>5.wikipedia</p><p>6.pyjokes</p><p><strong>Program:</strong></p><p>import speech_recognition as sr</p><p>import pyttsx3</p><p>import pywhatkit</p><p>import datetime</p><p>import wikipedia</p><p>import pyjokes</p><p>import sys</p><p># Initialize the recognizer and the text-to-speech engine</p><p>listener = sr.Recognizer()</p><p>engine = pyttsx3.init()</p><p># Get the available voices</p><p>voices = engine.getProperty(‘voices’)</p><p># Set the voice to the second voice if available, otherwise use the first voice</p><p>if len(voices) &gt; 1:</p><p>engine.setProperty(‘voice’, voices[1].id)</p><p>else:</p><p>engine.setProperty(‘voice’, voices[0].id)</p><p>def engine_talk(text):</p><p>print(f”Alexa is saying: {text}”) # Debug statement</p><p>engine.say(text)</p><p>engine.runAndWait()</p><p>def user_commands():</p><p>try:</p><p>with sr.Microphone() as source:</p><p>listener.adjust_for_ambient_noise(source) # Adjust for ambient noise</p><p>print(“Start Speaking!!”)</p><p>voice = listener.listen(source)</p><p>command = listener.recognize_google(voice)</p><p>command = command.lower()</p><p>if ‘alexa’ in command:</p><p>command = command.replace(‘alexa’, ‘’)</p><p>print(f”User said: {command}”) # Debug statement</p><p>return command</p><p>except Exception as e:</p><p>print(f”Error: {e}”) # Debug statement</p><p>return “ ”</p><p>def run_alexa():</p><p>command = user_commands()</p><p>if command:</p><p>if ‘play’ in command:</p><p>song = command.replace(‘play’, ‘’)</p><p>engine_talk(‘Playing ‘ + song)</p><p>pywhatkit.playonyt(song)</p><p>elif ‘time’ in command:</p><p>time = datetime.datetime.now().strftime(‘%I:%M %p’)</p><p>engine_talk(‘The current time is ‘ + time)</p><p>elif ‘who is’ in command:</p><p>name = command.replace(‘who is’, ‘’)</p><p>info = wikipedia.summary(name, 1)</p><p>print(info)</p><p>engine_talk(info)</p><p>elif ‘joke’ in command:</p><p>engine_talk(pyjokes.get_joke())</p><p>elif ‘stop’ in command:</p><p>sys.exit()</p><p>else:</p><p>engine_talk(‘I could not hear you properly’)</p><p>else:</p><p>engine_talk(‘I did not catch that. Please speak again.’)</p><p>while True:</p><p>run_alexa()</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96f20723501b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[License Plate Recognition]]></title>
            <link>https://medium.com/@dharshaan2004/license-plate-recognition-f8eecce38ec0?source=rss-c447a6ff30a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8eecce38ec0</guid>
            <dc:creator><![CDATA[Dharshaan]]></dc:creator>
            <pubDate>Wed, 26 Jun 2024 16:55:27 GMT</pubDate>
            <atom:updated>2024-06-26T17:00:59.757Z</atom:updated>
            <content:encoded><![CDATA[<p>LPR (License Plate Recognition) is an image-processing technology used to identify vehicles by their license plates. This technology is used in various security and traffic applications, such as the access-control system featured in the following animation.</p><p>•Canny edge detection is a popular image processing technique used to find edges in images. It works by detecting areas of rapid intensity change, which often correspond to the boundaries of objects in a scene.</p><p>•For eg:-</p><p>•Imagine you have a black-and-white picture, and you want to find all the edges in the image (where one object ends and another begins). Canny edge detection helps you do that.</p><p>•<strong>Noise Reduction</strong></p><p>•<strong>Gradient Calculation</strong></p><p>•<strong>Non-maximum Suppression</strong></p><p>•<strong>Thresholding</strong></p><p>•<strong>Edge Tracking by Hysteresis</strong></p><p><strong>Noise Reduction:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*tH0KUqBlCMRWIcaMdhCZPQ.png" /></figure><p>Original image (left) — Blurred image with a Gaussian filter (sigma=1.4 and kernel size of 5x5)</p><p><strong>Gradient Calculation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*WCmvBIvFFT9nNmo8pPyMQQ.png" /></figure><p>Blurred image (left) — Gradient intensity (right)</p><p><strong>Non-maximum Suppression:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/1*rghaiAuI_2bizOJ7UmN7aA.png" /></figure><p>Result of the non-max suppression.</p><p><strong>Thresholding:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*Os_wKf3nIxgWug0PKHhoVA.png" /></figure><p>Non-Max Suppression image (left) — Threshold result (right): weak pixels is gray and strong ones in white.</p><p><strong>Edge Tracking by Hysteresis:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*l4-Tnwlgtv7khGbvlJyy7g.png" /></figure><p>Results of hysteresis process</p><p><strong>Final:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/1*ii9O1dKoVThz8NLYRjwG9A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*74nTT776tXLlnY3cQdF0pA.png" /></figure><p><strong>Workflow:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xPmX3uiGh8tQy_hZZm6H1w.png" /></figure><p><strong>program:</strong></p><p>import cv2</p><p>import pytesseract</p><p>pytesseract.pytesseract.tesseract_cmd = ‘C:/Program Files/Tesseract-OCR/tesseract.exe’</p><p># Read the image file</p><p>image = cv2.imread(‘car1.JPG’)</p><p>cv2.imshow(“Original”,image)</p><p># Convert to Grayscale Image</p><p>gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)</p><p>cv2.imshow(“gray_image”, gray_image)</p><p>#Canny Edge Detection</p><p>canny_edge = cv2.Canny(gray_image, 170, 200)</p><p>cv2.imshow(“canny_edge”, canny_edge)</p><p># Find contours based on Edges</p><p>contours, new = cv2.findContours(canny_edge.copy(), cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)</p><p>contours=sorted(contours, key = cv2.contourArea, reverse = True)[:30]</p><p># Initialize license Plate contour and x,y,w,h coordinates</p><p>contour_with_license_plate = None</p><p>license_plate = None</p><p>x = None</p><p>y = None</p><p>w = None</p><p>h = None</p><p># Find the contour with 4 potential corners and create ROI around it</p><p>for contour in contours:</p><p># Find Perimeter of contour and it should be a closed contour</p><p>perimeter = cv2.arcLength(contour, True) #measure of the length of the outline of an object</p><p>approx = cv2.approxPolyDP(contour, 0.01 * perimeter, True)</p><p>print(“approx”,len(approx))</p><p>if len(approx) == 4: #see whether it is a Rect</p><p>contour_with_license_plate = approx</p><p>x, y, w, h = cv2.boundingRect(contour)</p><p>license_plate = gray_image[y:y + h, x:x + w]</p><p>break</p><p>(thresh, license_plate) = cv2.threshold(license_plate, 127, 255, cv2.THRESH_BINARY)</p><p>cv2.imshow(“plate”,license_plate)</p><p># Removing Noise from the detected image, before sending to Tesseract</p><p>license_plate = cv2.bilateralFilter(license_plate, 11, 17, 17)</p><p>#Text Recognition</p><p>text = pytesseract.image_to_string(license_plate)</p><p>#Draw License Plate and write the Text</p><p>image = cv2.rectangle(image, (x,y), (x+w,y+h), (0,0,255), 3)</p><p>image = cv2.putText(image, text, (x-100,y-20), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,255,0), 2, cv2.LINE_AA)</p><p>print(“License Plate :”, text)</p><p>cv2.waitKey(0)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8eecce38ec0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Drowsniess Detection]]></title>
            <link>https://medium.com/@dharshaan2004/drowsniess-detection-4a588f22d01b?source=rss-c447a6ff30a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a588f22d01b</guid>
            <category><![CDATA[drowsiness-detection]]></category>
            <dc:creator><![CDATA[Dharshaan]]></dc:creator>
            <pubDate>Sat, 08 Jun 2024 14:58:33 GMT</pubDate>
            <atom:updated>2024-06-08T14:58:33.734Z</atom:updated>
            <content:encoded><![CDATA[<p>•Drowsiness refers to feeling abnormally sleepy during the day. People who are drowsy may fall asleep in inappropriate situations or at inappropriate times.</p><p>•Driver drowsiness detection is a car safety technology which helps prevent accidents caused by the driver getting drowsy. Various studies have suggested that around 20% of all road accidents are fatigue-related, up to 50% on certain roads.</p><p><strong>Installing Libraries:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iv5D94v9rEaYkum7-deK7g.png" /></figure><p>PyQt5: <strong>pip install sklearn ; pip install dlib</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*kGiE0yHySRuGnu3a4YYQCQ.jpeg" /></figure><p><strong>dlib’s facial landmark detector:</strong></p><p>•The pre-trained facial landmark detector inside the dlib library is used to estimate the location of 68 (x, y)-coordinates that map to facial structures on the face.</p><p>•Facial landmarks are used for localizing and representing salient regions or facial parts of the person’s face, such as:</p><p>•Nose</p><p>•Jaws</p><p>•Left eye</p><p>•Right eye</p><p>•Left eyebrow</p><p>•Mouth</p><p>•Right eyebrow</p><p><strong>Diagram:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*kHMjAp4rAVWKJBNwduiShA.png" /></figure><p>The Locations of the Facial Parts are as follows:</p><p>•The left eye is accessed with points [42, 47].</p><p>•The mouth is accessed through points [48, 67].</p><p>•The left eyebrow is accessed through points [22, 26].</p><p>•The nose is accessed using points [27, 34].</p><p>•The right eyebrow is accessed through points [17, 21].</p><p>•The right eye is accessed using points [36, 41].</p><p>•And the jaw is accessed via points [0, 16].</p><p><strong>WorkFlow:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TW6LxBzC1sczHqEzMk850w.jpeg" /></figure><p><strong>program:</strong></p><p>from scipy.spatial import distance as dist<br>from imutils import face_utils<br>import imutils<br>import dlib<br>import cv2<br>import winsound<br>frequency = 2500<br>duration = 1000</p><p>def eyeAspectRatio(eye):<br> #Vertical<br> A = dist.euclidean(eye[1], eye[5])<br> B = dist.euclidean(eye[2], eye[4])<br> #Horizontal<br> C = dist.euclidean(eye[0], eye[3])<br> ear = (A + B) / (2.0 * C)<br> return ear</p><p>count = 0</p><p>earThresh = 0.3 #distance between vertical eye coordinate Threshold<br>earFrames = 48 #consecutive frames for eye closure<br>shapePredictor = “shape_predictor_68_face_landmarks.dat”</p><p>cam = cv2.VideoCapture(0)<br>detector = dlib.get_frontal_face_detector()<br>predictor = dlib.shape_predictor(shapePredictor)</p><p>#get the coord of left &amp; right eye<br>(lStart, lEnd) = face_utils.FACIAL_LANDMARKS_IDXS[“left_eye”]<br>(rStart, rEnd) = face_utils.FACIAL_LANDMARKS_IDXS[“right_eye”]</p><p>while True:<br> _, frame = cam.read()<br> frame = imutils.resize(frame, width=450)<br> gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)</p><p>rects = detector(gray, 0)</p><p>for rect in rects:<br> shape = predictor(gray, rect)<br> shape = face_utils.shape_to_np(shape)</p><p>leftEye = shape[lStart:lEnd]<br> rightEye = shape[rStart:rEnd]</p><p>leftEAR = eyeAspectRatio(leftEye)<br> rightEAR = eyeAspectRatio(rightEye)</p><p>ear = (leftEAR + rightEAR) / 2.0</p><p>leftEyeHull = cv2.convexHull(leftEye)<br> rightEyeHull = cv2.convexHull(rightEye)<br> cv2.drawContours(frame, [leftEyeHull], -1, (0, 0, 255), 1)<br> cv2.drawContours(frame, [rightEyeHull], -1, (0, 0, 255), 1)</p><p>if ear &lt; earThresh:<br> count += 1</p><p>if count &gt;= earFrames:<br> cv2.putText(frame, “DROWSINESS DETECTED”, (10, 30),<br> cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)<br> winsound.Beep(frequency, duration)<br> else:<br> count = 0</p><p>cv2.imshow(“Frame”, frame)<br> key = cv2.waitKey(1) &amp; 0xFF</p><p>if key == ord(“q”):<br> break</p><p>cam.release()<br>cv2.destroyAllWindows()</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a588f22d01b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>