<?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 Srijita Tiwari on Medium]]></title>
        <description><![CDATA[Stories by Srijita Tiwari on Medium]]></description>
        <link>https://medium.com/@srijitatiwari?source=rss-5f04ee312bca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3jZYU36ime8QZMC--Un55w.jpeg</url>
            <title>Stories by Srijita Tiwari on Medium</title>
            <link>https://medium.com/@srijitatiwari?source=rss-5f04ee312bca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:32:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@srijitatiwari/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[People Count in Retail Industry using CV]]></title>
            <link>https://srijitatiwari.medium.com/people-count-in-retail-industry-how-retail-industry-counts-people-e6fa037d898a?source=rss-5f04ee312bca------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6fa037d898a</guid>
            <category><![CDATA[realtime-video-processing]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[haar-cascades]]></category>
            <category><![CDATA[people-counter]]></category>
            <dc:creator><![CDATA[Srijita Tiwari]]></dc:creator>
            <pubDate>Fri, 21 May 2021 05:18:55 GMT</pubDate>
            <atom:updated>2021-09-02T09:18:31.452Z</atom:updated>
            <content:encoded><![CDATA[<h3>Aim</h3><p>In this blog, we will discuss popular people count methods, along with some tasks done in video processing to have better results. There are some algorithms like Haar Cascade, HOG, and OpenCV methods that are used in people detection. After having an understanding of these methods along with their advantages, we can employ these methods in the people counting use case as discussed below.</p><p>Our aim is to find the number of people inside the store at a particular hour (dwell time) and the number of people at various sections (groceries, beverages, etc) inside the retail store with the help of CCTV footages. To perform this task, CCTV videos at the entry point, and at different sections inside the store are required.</p><p>The video below shows a typical CCTV footage of a retail store, having various sections of the store in the field of view.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FQy_m-tLjFvc&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQy_m-tLjFvc&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FQy_m-tLjFvc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d980692d10c7d975e5256014b780e06/href">https://medium.com/media/7d980692d10c7d975e5256014b780e06/href</a></iframe><h3>Algorithms</h3><p>Let’s discuss some of the people detection algorithms along with the approach used in this blog:</p><p><strong>1. Haar Cascade people Detection Algorithm- </strong>It is an ML-based approach where a cascade function is trained from a lot of positive and negative images. Pre-trained cascades are used in detection. Learn more about this method here: <a href="https://towardsdatascience.com/computer-vision-detecting-objects-using-haar-cascade-classifier-4585472829a9">cascade</a>.</p><p>Below is the code for it :</p><p><em>import numpy as np</em></p><p><em>import cv2# Create our body classifier</em></p><p><em>body_classifier = cv2.CascadeClassifier(‘haarcascade_fullbody.xml’)# Initiate video capture for video file</em></p><p><em>cap = cv2.VideoCapture(‘/moskva.mov’)# Loop once video is successfully loaded</em></p><p><em>while cap.isOpened():</em></p><p><em># Read first frame</em></p><p><em>ret, frame = cap.read()</em></p><p><em>gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)</em></p><p><em># Pass frame to our body classifier</em></p><p><em>bodies = body_classifier.detectMultiScale(gray, 1.1, 3)</em></p><p><em># Extract bounding boxes for any bodies identified</em></p><p><em>for (x,y,w,h) in bodies:</em></p><p><em>cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 255), 2)</em></p><p><em>cv2.imshow(‘Pedestrians’, frame)</em></p><p><em>if cv2.waitKey(1) == 13: #13 is the Enter Key</em></p><p><em>break</em></p><p><em>cap.release()</em></p><p><em>cv2.destroyAllWindows()</em></p><p><strong>2. Simple HOG detection- </strong>HOG(Histogram of Gradients) is a type of “feature descriptor”. The technique counts occurrences of gradient orientation in localized portions of an image and thereby in a video. Learn more about this method here: <a href="https://learnopencv.com/histogram-of-oriented-gradients/">hog</a>.</p><p>Below is the code for it :</p><p><em>import cv2<br> import imutils<br> # Initialising HOG person detector<br> hog = cv2.HOGDescriptor<br> hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector)<br> # Reading the Image<br> image = cv2.imread(‘img.png’)<br> # Resizing the Image<br> image = imutils.resize(image,<br> width=min(400, image.shape[1]))<br> # Detecting all the regions in the Image that has a pedestrians inside it<br> (regions, _) = hog.detectMultiScale(image, winStride=(4, 4), padding=(4, 4), scale=1.05)<br> # Drawing the regions in the Image<br> for (x, y, w, h) in regions:<br> cv2.rectangle(image, (x, y), (x + w, y + h), (0, 0, 255), 2)<br> # Showing the output Image<br> cv2.imshow(“Image”, image)<br> cv2.waitKey(0)<br> cv2.destroyAllWindows()</em></p><p><strong>3. OpenCV background subtraction- </strong>Background subtraction is a major preprocessing step in many vision-based applications. For example, consider the cases like a visitor counter where a static camera takes the number of visitors entering or leaving the room, or a traffic camera extracting information about the vehicles, etc. In all these cases, first, you need to extract the person or vehicles alone. Technically, you need to extract the moving foreground from static background. It is a relatively faster method for real-time people detection. OpenCV has implemented three such algorithms :</p><ol><li>BackgroundSubtractorMOG</li><li>BackgroundSubtractorMOG2</li><li>BackgroundSubtractorGMG</li></ol><p>Learn more about these here: <a href="https://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_video/py_bg_subtraction/py_bg_subtraction.html">opencv</a></p><p>Below is the implementation of OpenCV background subtraction using BackgroundSubtractorMOG2:</p><p><em>import numpy as np</em></p><p><em>import cv2</em></p><p><em>cap = cv2.VideoCapture(‘vtest.avi’)</em></p><p><em>fgbg = cv2.createBackgroundSubtractorMOG2()</em></p><p><em>while(1):</em></p><p><em>ret, frame = cap.read()</em></p><p><em>fgmask = fgbg.apply(frame)</em></p><p><em>cv2.imshow(‘frame’,fgmask)</em></p><p><em>k = cv2.waitKey(30) &amp; 0xff</em></p><p><em>if k == 27:</em></p><p><em>break</em></p><p><em>cap.release()</em></p><p><em>cv2.destroyAllWindows()</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VvEwTMwCYFEi5uNwNWKvhQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yMOBGxkcz2n-m9CH.png" /></figure><p>Source : <a href="https://docs.opencv.org/3.4/d1/dc5/tutorial_background_subtraction.html">https://docs.opencv.org/3.4/d1/dc5/tutorial_background_subtraction.html</a></p><p>The second image shows the OpenCV background subtraction results on the first image.</p><p>Our approach uses this method for better results. Contour methods and morphological transformations have been used to count people with more accuracy.</p><p><strong>4. HOG with linear SVM algorithm- </strong>The accuracy of the HOG detector (discussed in the Simple HOG detection method) can be further improved by using an SVM classifier to classify positive and negative features from sample images.</p><p>The extracted positive and negative features from collected positive and negative image samples are used to train the SVM model with HOG detection. This method counts traffic with maximum accuracy and the algorithm can be customized. Negative images (background images of retail stores) can be generated for any new store to increase the accuracy.</p><h3>Approach</h3><p>Comparison of the above-mentioned algorithms :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hPVLMFifaE89nlZe.png" /></figure><p>Source : self project work</p><p>Let’s look at the approach used in this blog, based on the above observation, keeping in mind the different type of videos that we get from the retail store:</p><h3>Splitting of videos</h3><p>Splitting of the store layout video is done for effective traffic count at various categories from a single camera view. One footage might cover 2–3 categories like beverage, grocery sections. To get accurate people — count at different sections of the store, splitting is helpful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gNHS3Jyzg_pk8Pus.png" /></figure><p>Source : self project work</p><p>As can be seen in the image above, CCTV videos are available at a bay level so to measure the traffic at a category level, the video coverage area is split into categories area-wise.</p><h3>Results</h3><p>In the use case, our main task is to have an estimate of the count of people inside the store(and also in various sections of the store) to analyze dwell time. Having discussed the algorithms and approaches suitable for the given case, let’s look at the results :</p><p><strong>Entrance/Exit Camera Video</strong></p><p>The algorithm used:- Opencv background subtractor</p><p>Reason:- Fast detections are done because people usually enter at a relatively fast speed (as compared to slow movement inside the store). The people are detected when they cross the camera view.</p><p>Result:-</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNjzOgGNVnqw%3Fstart%3D1%26feature%3Doembed%26start%3D1&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNjzOgGNVnqw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNjzOgGNVnqw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8ba50423140d45c5dbf6b987564553a/href">https://medium.com/media/f8ba50423140d45c5dbf6b987564553a/href</a></iframe><p><strong>Camera videos above various sections inside the store</strong></p><p>The algorithm used:- HOG (linear SVM classifier)</p><p>Reason:- Accurate detection is needed since people usually walk with trolleys/children. This algorithm is best for this case scenario</p><p>Result:-</p><p>Grocery section people count in every frame :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFSZ8loBRtJQ%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFSZ8loBRtJQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFSZ8loBRtJQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/9a72b333347cbf388cbc4ef523e9776f/href">https://medium.com/media/9a72b333347cbf388cbc4ef523e9776f/href</a></iframe><p>Beverage section people count in every frame :</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3sZHfWMZgdk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3sZHfWMZgdk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3sZHfWMZgdk%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b556bf772468a8393da238d59c311a58/href">https://medium.com/media/b556bf772468a8393da238d59c311a58/href</a></iframe><p>Let me know in the comments in case of any approach that may further enhance the results.</p><p><em>Originally published at </em><a href="https://www.analyticsvidhya.com/blog/2021/05/people-count-in-a-retail-store/"><em>https://www.analyticsvidhya.com</em></a><em> on May 21, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6fa037d898a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Highlight elimination for vehicle detection at night time]]></title>
            <link>https://srijitatiwari.medium.com/highlight-elimination-for-vehicle-detection-at-night-time-2d046f906a8c?source=rss-5f04ee312bca------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d046f906a8c</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[video-analysis]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[vehicle-detection]]></category>
            <dc:creator><![CDATA[Srijita Tiwari]]></dc:creator>
            <pubDate>Wed, 14 Apr 2021 06:16:27 GMT</pubDate>
            <atom:updated>2021-09-02T09:04:00.984Z</atom:updated>
            <content:encoded><![CDATA[<h3>Table of contents</h3><ol><li>Introduction</li><li>Methodology</li><li>Further modifications</li><li>Results</li><li>Conclusion and future work</li></ol><h3>Introduction</h3><p>Detection of vehicles on road scenes is the first step in a vision-based traffic surveillance system. There are many motion-based approaches for vision-based vehicle detection.</p><p>Background modeling is a common approach to achieve this, in which the moving vehicles are considered the foreground and stationary regions of the scene, i.e. road, are considered the background.</p><p>The extracted foreground at night time or in the dim light from background modeling techniques contains the vehicles as well as highlights.</p><p>As discussed above, efficient vehicle detection is crucial in many traffic surveillance projects. Much work has been done for vehicle detection in the daytime. Night-time surveillance videos face problems to detect vehicles because of many reasons. Highlights from vehicle headlights falling on the road is one such major cause of interference in detection. This added interference in the detection of vehicles, due to highlights can further lead to overestimation of vehicle sizes or erroneous vehicle tracking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/0*o61su-Cd2w1XY3NV.png" /></figure><p><a href="https://www.youtube.com/watch?v=O5RPr3qufuE&amp;ab_channel=vladakuc">Source</a></p><p>Having discussed the motivation behind this blog let’s understand the methodology to solve the problem at hand.</p><h3>Methodology</h3><p>Let’s go through 2 main methods that help is efficient vehicle detection at night time :</p><p>1. <strong>Edge threshold</strong> — Let’s observe the image below which shows the boundary edge map of the frame (after applying Sobel filter on foreground mask) boundary edge map is evaluated. As can be clearly seen, the vehicle has sharp edges. This factor is utilized in the project and foreground blocks that contain interior edge pixels(&gt; threshold) are classified as vehicles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/0*mNbGocbJ8dfem5nk.png" /></figure><p><a href="https://arxiv.org/pdf/1410.5894.pdf">Source</a></p><p>2.<strong> Intensity factor</strong> — In a frame containing these 3 objects: vehicle, highlight, and dark background (since night time videos are used), a very useful difference are of the intensity level. Since highlights are brighter than vehicles, an optimum threshold is applied to distinguish high-intensity blocks from low-intensity blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/0*xfFPYcKsYOYkokpH.png" /></figure><h3>Further modifications</h3><p>Following factors have also been included along with the above methods to resolve some more issues in vehicle detection at night time :</p><p>1. <strong>Size constraint</strong>: A big distinguishing factor between vehicles and highlights is the size/ number of blocks they fall in. The vehicle occupies many continuous blocks in each direction(can be thought of as a rectangle) whereas highlight would occupy fewer blocks. A threshold of 2–3 continuous blocks occupancy in each direction was applied to remove highlight blocks.</p><p>2. <strong>Lone highlights</strong>: Sometimes the highlights of street lights also interfere with vehicle detection. Such type of lights which occupy less area in foreground block is termed as lone highlights. Area constraint (less than 5% foreground pixels in a foreground block) was applied to remove such lone highlights.</p><p>3. <strong>HSV color factor</strong>: Sometimes the vehicle is not fully detected, due to less bright regions inside the vehicle or less edgy pixels. When the vehicle moves frame by frame the hue of the vehicle remains constant and this property can be exploited in detecting the whole or maximum of the vehicle. The three parameters of HSV color were tried for various constraints to find the suitable combination for better detection.</p><h3>Results</h3><p>1. In the first set of results let’s see how the methodology works on video footage at night time.</p><p>Applying <strong>edge sum threshold</strong> and optimum <strong>intensity factor</strong>: In the two images below, we can see the high edge sum values are getting detected based on the threshold that we apply.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/0*hG6sMZ5w0SJ5-icO.png" /></figure><p>Edge sum threshold = 35, Source : self project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*Ocb48u7wZUnkbwY0Lquzyg.png" /></figure><p>Edge sum threshold = 45, Source : self project</p><p>In the first image highlight falling on the road is also getting detected along with the car whereas in the second image almost the whole car is getting detected and the highlight on road is also decreased.</p><p>2. In the second set of results, the use of <strong>HSV factor </strong>is depicted :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/0*PS9q7wEOD7Z9giX1.png" /></figure><p>Before applying any hue constraint, Source : self project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*ilegXWCF5dkaX3da76lCwQ.png" /></figure><p>After applying red hue constraint, Source: self project</p><p>As can be seen, in the second image a large portion of the bus is getting detected after applying the red hue constraint.</p><h3>Conclusion and future work</h3><p>We have discussed the methods that are used for the removal of highlights that interfere with vehicle detection mainly at night time. More work can be done in this field as there are many issues that remain unresolved as listed below:</p><ol><li>Hole filling may be applied for efficient vehicle detection.</li><li>Much better detection of white color vehicles (as their hue matches with that of highlight) may be done.</li><li>Weather conditions like rain and storm can further lead to errors in the above-mentioned methods. They need to be handled separately.</li></ol><p><em>Originally published at </em><a href="https://www.analyticsvidhya.com/blog/2021/04/highlight-elimination-for-vehicle-detection-at-night-time/"><em>https://www.analyticsvidhya.com</em></a><em> on April 14, 2021.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d046f906a8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>