<?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 Adityaojas Sharma on Medium]]></title>
        <description><![CDATA[Stories by Adityaojas Sharma on Medium]]></description>
        <link>https://medium.com/@adityaojas?source=rss-36d7ac3920d6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BmvjK727uzmlHqOM</url>
            <title>Stories by Adityaojas Sharma on Medium</title>
            <link>https://medium.com/@adityaojas?source=rss-36d7ac3920d6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 07:49:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adityaojas/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[10 flags you should enable right away if you work on Google Chrome!]]></title>
            <link>https://adityaojas.medium.com/10-flags-you-should-enable-right-away-if-you-work-on-google-chrome-cd03032026ab?source=rss-36d7ac3920d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd03032026ab</guid>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[chrome]]></category>
            <category><![CDATA[hacks]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Adityaojas Sharma]]></dc:creator>
            <pubDate>Fri, 16 Oct 2020 09:46:04 GMT</pubDate>
            <atom:updated>2020-10-16T10:55:36.304Z</atom:updated>
            <content:encoded><![CDATA[<p>Okay, the last article I wrote was fairly technical, diving into AI and Pose Estimation and all those tech tidbits. But this right here, guys, is one of those which may simply enlighten just anybody out there! And I mean it.</p><p>Yes, as the title suggests, Chrome Flags! You might as well call these tips and tricks, or even hacks, that would make your web browsing lives damn easier. All in all, here are a few things you should know if you work with Chrome. Otherwise, you’re just missing out on too much!</p><p>A bit of a layman background on it — umm, Chrome actually maintains a repository of experimental features, which are not yet deployed. And these can be accessed by simply typing ‘chrome://flags’ in the URL bar of the browser and pressing enter!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F468511790%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F468511790&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F975683418_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfba752728639ff5eaaba08d8e0236e8/href">https://medium.com/media/cfba752728639ff5eaaba08d8e0236e8/href</a></iframe><p>And there you go, hundreds of ‘under the hood’ features at your disposal! And in this article, I will take you through the coolest of those that you can make use of (dated Oct 2020).</p><p>Before starting, here is a video demonstration on my Youtube Channel giving a use-case demo of the Top-5 of these flags that come in so handy. Every. Single. Day. You’ll love it!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fb9_ECoTY1mI&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Db9_ECoTY1mI&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/abe7c38da673264c19a4472706ff41a4/href">https://medium.com/media/abe7c38da673264c19a4472706ff41a4/href</a></iframe><p>Alright, here we go!</p><h4>Tab Groups</h4><p>I bet many of you must have found yourselves in a situation while browsing when you end up opening so many tabs in a single window, and that kinda messes the mood up! If you hate that as well, here are tab groups at your disposal!</p><p>Chrome is actually rolling this feature out slowly, but nevertheless, you should know about it.</p><p>Now to get these, like said before, type in ‘chrome://flags’ in the URL bar. Search for tab groups. Enable 1) #tab-groups &amp; 2) #tab-groups-collapse (This will let you collapse your tab group on clicking on it, which is a pretty neat thing to look at)</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F468511624%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F468511624&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F975684488_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/040925e75d77192d06c7eaf4844dc70a/href">https://medium.com/media/040925e75d77192d06c7eaf4844dc70a/href</a></iframe><p>Relaunch the browser, and you’re good to play with the feature. By right-clicking on any tab, you add it to a new group or an existing group. Whatever works for you. You can even name and assign a color to the group. Pretty sleek!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F468868886%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F468868886&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F976277710_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/32c9396ea7b2b91cd15fa92ceab01dc6/href">https://medium.com/media/32c9396ea7b2b91cd15fa92ceab01dc6/href</a></iframe><h4>Hover Cards</h4><p>Now, this comes in really handy when you have so, soo many tabs opened, and you want to fly back to a particular webpage, but can’t really remember which tab it is in (because maybe the titles are cropped). Here’s what you need, tab preview cards!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F468511674%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F468511674&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F975683847_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ec00eb21e36c170f00b5ebb34f03ae4/href">https://medium.com/media/7ec00eb21e36c170f00b5ebb34f03ae4/href</a></iframe><p>You see, you just need to hover the cursor on the tab to get a preview of what it is.</p><p>To get this, the same story — Chrome Flags. You’ll have to enable 1) #tab-hover-card, and 2) #tab-hovercard-images.</p><p>You got it!</p><h4>QR Code Generator</h4><p>Let’s say you are browsing on Facebook on your PC, and you come across something that you wanna open up on your phone/ tablets. Can be anything for that matter, any URL on the internet you wanna open up on your phones. What would you do? Here’s what I do -</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F468823462%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F468823462&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F976190704_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/1347841750b1e60784c49d306ca20ad4/href">https://medium.com/media/1347841750b1e60784c49d306ca20ad4/href</a></iframe><p>A one-click QR Code Generator for any URL that you find on the internet! Amazing right. The name of the flag is <strong>#sharing-qr-code-generator</strong>. Go on, enable it.</p><h4>Picture-In-Picture Mode</h4><p>Again, Chrome is slowly rolling this one out in the stable version but if you’re a multi-tasker, just wanna make sure y’all know this! Wanna watch some Netflix (or any video for that matter) while reading a Medium article? Or writing a report? And yes, on the same screen (same tab). Got you there!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F468511771%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F468511771&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F975683585_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/38ecde2fa3e10cfd36bb9f1ff38723b9/href">https://medium.com/media/38ecde2fa3e10cfd36bb9f1ff38723b9/href</a></iframe><p>Interesting, right? All you have to do is enable the <strong>#global-media-controls-picture-in-picture</strong> Flag on the Experiments page!</p><h4>Dark Mode</h4><p>One for the dark mode lovers here. You’ll be damned to know that using this flag you’d be able to force a dark mode on ANY website in the world. Yes, even Google, or LinkedIn.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F468835071%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F468835071&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F976212570_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/272e516e510531761464039106fad6f8/href">https://medium.com/media/272e516e510531761464039106fad6f8/href</a></iframe><p>All you have to do is enable the <strong>#enable-force-dark</strong> flag. And you’re good to go.</p><p>But here’s one catch. It would have been amazingly convenient if the flag could provide a tag somewhere on the toolbar to switch between the dark and normal modes. The dark mode doesn’t really suit some of the webpages.</p><h4>Faster Downloading</h4><p>You might as well guess this from the title of how amazing this one is! The ‘Parallel Downloading’ Flag accelerates the downloading process by breaking the file into smaller chunks, and downloading, umm, parallelly. In other words, similar to what IDM and other cool downloading managers do!</p><p>So go on, search for the <strong>#enable-parallel-downloading</strong> Flag, and switch it on!</p><h4>Reader Mode</h4><p>Those of you who’ve used Safari might know about the read mode feature they have for a smooth experience while reading articles! Good news, Chrome has added a similar flag to its list!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F468823490%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F468823490&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F976190739_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cd704584eefd9373c213d3c15ea6864/href">https://medium.com/media/7cd704584eefd9373c213d3c15ea6864/href</a></iframe><p>This one allows you to remove all the glitter and unnecessary advertisements from the article webpage. Now, it’s not available for every website, but many of the blog posts. Pretty neat!</p><p>Switch on the #enable-reader-mode flag and you got it!</p><h4>Clipboard Sharing among devices</h4><p>Have you seen one of those AR videos where the person clicks a picture on his/her phone and transfers it to the PC by simply waving it? I am sorry, don’t get your expectations too high, but this one is very lightly similar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ej2EYkobrKJQJFk0aG3KXQ.jpeg" /><figcaption>Enable the flag, transfer the clipboards to connected devices</figcaption></figure><p>You can copy something on your browser on your Android phones and transfer that to your PC Clipboard. It can be a long ass article or a URL that you want to open up on your PC.</p><p>And for that, you’ll have to switch on the flags on your phone browser and PC browser, both. The flag for your phone would <strong>#shared-clipboard-ui</strong> and the flag you need to enable on your PC would be <strong>#remote-copy-receiver</strong>.</p><h4>Google Lens (Android)</h4><p>Another one for the Android Users. You can now use google lens by simply holding the image for a while and clicking on Google Lens on the dropdown!</p><p>Enable it by switching on <strong>#context-menu-search-with-google-lens</strong></p><p>In fact, you can play around with other Google Lens flags that you may find on searching google lens on your phones. Do comment if you find something cool, LOL!</p><h4>Smooth Scrolling (Android)</h4><p>Not much to say about it, since the name says it all. It makes the scrolling on heavy webpages, like Reddit, amazingly smooth. And that brings it to the top 10, tbh!</p><p>#smooth_scrolling is the flag that you’d enable to get this feature on your phones.</p><h4>A few more...</h4><p>the repository is pretty vast, and just 10 flags won’t really do justice or reflect how awesome these flags can be! So here are a few more flags that you can check out</p><ul><li>#read-later: lets you save tabs for accessing later</li><li>#quiet-notification-prompts: to avoid the annoying notification prompts on every other website</li><li>#live-captions: generates caption for nearly any video playing on your browser</li><li>#extension-toolbar-menu: if the piled up extensions near your address bar annoy you then use this</li><li>#enable-lazy-image-loading &amp; #enable-lazy-frame-loading: would load the images and frames only when the user scrolls there. Hence, would load your webpages faster</li><li>#interest-feed-content-suggestions (Android): would bring a suggestion-card UI on the home page when you open the browser</li><li>#enable-tab-groups-ui-improvements (Android): A toolbar would be created on the bottom of your screens to navigate through tabs easily!</li></ul><p>And many more…</p><p>Now here’s the question of the day,</p><h4>Are Chrome Flags safe?</h4><p>And the answer is, Yes! They very much are safe. Especially the ones that I have mentioned in this article are tested. They might just a bit unstable sometimes based on the version of Chrome or OS that you use, or if you end up switching just TOO MANY flags on.</p><p>Also, these flags are supported on other Chromium-based Browsers as well.</p><p>Even Edge has its own repository of such experiments which can be accessed on ‘edge://flags’.</p><p>With this, I’d conclude this article on some of the most useful Chrome Flags that you can enable for daily use! Would love to hear what you think about these, down in the comments, and if any of these manages to become your favorite!</p><p>Also, do share if you come across any such flag that you think has the potential to make it up to the top 10.</p><p>Thanks for Reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd03032026ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cleaner Pose Estimation using Open Pose]]></title>
            <link>https://adityaojas.medium.com/cleaner-pose-estimation-using-open-pose-6d239cc33fe6?source=rss-36d7ac3920d6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d239cc33fe6</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[pose-estimation]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[jump-rope]]></category>
            <dc:creator><![CDATA[Adityaojas Sharma]]></dc:creator>
            <pubDate>Wed, 23 Sep 2020 07:16:20 GMT</pubDate>
            <atom:updated>2020-09-23T07:35:11.224Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KSyYPECzQer5k3FbMcQTOw.png" /><figcaption>Pose Estimation</figcaption></figure><p>Here it is, finally! One of the most awaited articles of all time, and that’s apparently the first one I am writing! Eh, just kidding. This is just one of my, yet another, nerd-attempts to share some knowledge. But this time it is on a new platform. (I’ve always wanted to write on Medium)</p><p>Anyway, much with the introduction, this article is essentially about one of the hottest topics in Computer Vision these days, and that’s Pose Estimation! And if you have ever worked on it, you might realize that it doesn’t sometimes give a very clear demonstration. In this article, we will be additionally solving that issue using some post-processing!</p><p>Human Pose Estimation (HPE) is an important problem that has enjoyed the attention of the Computer Vision community for the past few decades.</p><p>It primarily involves localization of human joints (also known as keypoints — elbows, wrists, etc) in images or videos, and hence, analyzing the presence of specific poses in a space of all articulated poses. It is a crucial step towards understanding people in images and videos.</p><p>HPE has been used as the backbone of pretty cool applications like Action Recognition, Workout Form Correction, etc., and plays a vital role in a range of fields like Augmented Reality, Animation, Gaming, Robotics, etc.</p><p>And these are apparently the coolest fields to get your hands-on, and that gives HPE all the spotlight!</p><p>I won’t be really be going into details on how HPE works and the different architectures/ approaches, but here’s a snippet of how it looks like. I am pretty sure you’d love it!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FgEhNntwJSdY%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DgEhNntwJSdY&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FgEhNntwJSdY%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/04deb5b220b774434eb0c1409d74a6fb/href">https://medium.com/media/04deb5b220b774434eb0c1409d74a6fb/href</a></iframe><p>A simple Jump Rope Application I made using HPE. Let’s save this topic for the next article.</p><p>Anyway, if you’re interested in having a detailed understanding of HPE, here are a few sources I would recommend:</p><ul><li><a href="https://www.fritz.ai/pose-estimation/">https://www.fritz.ai/pose-estimation/</a></li><li><a href="https://nanonets.com/blog/human-pose-estimation-2d-guide/">https://nanonets.com/blog/human-pose-estimation-2d-guide/</a></li></ul><p>Let’s jump straight into the action and see how we can apply pose estimation on our own videos!</p><h3>Workflow</h3><p>I will be using ‘Open Pose’, an opensource pose estimation model by <a href="https://github.com/CMU-Perceptual-Computing-Lab">CMU Perceptual Computing Lab</a>, which is compatible with the OpenCV DNN module. So in an essence, we will be using mainly OpenCV for the whole project, topped by some post-processing using the SciPy module.</p><p>I assume that you already have a basic knowledge of using python, or at least have Python 3.x (x &gt;= 6 preferably) installed on your systems.</p><p>I highly recommend setting up an environment for all of the projects involving basic image processing and computer vision. I prefer, and am pretty comfortable using the conda interface for my projects.</p><p>Even if you use a different interface, I’d recommend that you get comfortable with anaconda at some point down the line as it is hands down one of the most convenient interfaces to use to practice Machine Learning and Computer Vision. To get started with conda, <a href="https://docs.conda.io/projects/conda/en/latest/user-guide/getting-started.html">here is the link</a> I would suggest you go through.</p><h3>Let’s get started!</h3><p>The libraries we’ll be using are majorly OpenCV, SciPy, NumPy, and Pandas added on with some helper libraries like progressbar, os, .csv, etc.</p><h4>Download the Repo and the Models</h4><p>We are using models trained on Caffe Deep Learning Framework. Caffe models have 2 files:</p><ul><li>.prototxt file which specifies the architecture of the neural network — how the different layers are arranged etc.</li><li>.caffemodel file which stores the weights of the trained model</li></ul><p>To download the .caffemodel file, <a href="http://posefs1.perception.cs.cmu.edu/OpenPose/models/pose/mpi/pose_iter_160000.caffemodel">click on this link</a>. Next step, simply clone/ download my GitHub Repo <a href="https://github.com/Adityaojas/Pose-Estimation-Clean-.git">here</a>. Once downloaded, jump into the models directory and paste the downloaded .caffemodel file here. That’s it, we are done with ‘downloading the model’ part of it.</p><p>Additionally, for the sake of simplicity and cleanliness, you can also make 2 new directories, samples and outputs, which as the names suggest would contain the input video and the output results respectively</p><h4>Let’s jump into the code.</h4><p>What we have in the repo are 2 .py files.</p><ul><li>The first one, <a href="http://open_pose.py/">open_pose.py</a>, is essentially the whole backbone. This file will parse through each frame of your video and will extract the coordinates of each joint apparent in the frame and save it in a .csv file. Some of you might have a nice question here, and the answer is — Yes, we can get a resulting stick figure composed on top of the video from this algorithm, but there are a few shortcomings, you’ll understand once we study the code. Hence, we have,</li><li><a href="http://clean_output.py/">clean_output.py</a>, which, will get us a cleaner output from the resulting .csv from the previous code.</li></ul><p>I’ll use the code gists here to explain what happens in both the codes before getting the results, so brace through if you wanna peep at what the py files are doing behind your back.</p><h4>First up — open_pose.py</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8071112f63f16250e6446a1479922bc7/href">https://medium.com/media/8071112f63f16250e6446a1479922bc7/href</a></iframe><p>The first 6 lines here import the needed libraries. Lines 9–14 define the needed paths that we’ll be using in the code. (You can alternatively use argparse to input these files directly from the terminal before running the code.)</p><p>Line 17 loads the model and the weights into the RAM using the OpenCV DNN module.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a87486a5889d99b1189d220e6ed9060/href">https://medium.com/media/4a87486a5889d99b1189d220e6ed9060/href</a></iframe><p>(I wish there was a way to continue the code block from line 18, but there isn’t. Sucks! Let me know if there is any, btw. I am a noob on Medium.)</p><p>In Lines 1–8 above, we initialize the input video from the previous block and define the different specifics of the video like the fps, number of frames, height, width, and the required output height and width (h, w). This is followed by defining the input height and width values required by the model. (We’ll be resizing each of the frames to these dimensions later.)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/868823e5f3bd60d35a794e9d964d0f86/href">https://medium.com/media/868823e5f3bd60d35a794e9d964d0f86/href</a></iframe><p>Lines 1–7 in this block initialize the output video writer.</p><blockquote>Now here’s an important catch! This particular part might not work on your systems.</blockquote><p>Yes, this can be a huge pain in the ass, and it sucks! The reason is you might have different codecs installed on your system. That is, the output extension here (apparently .mp4 here, defined above in the first block) might not be compatible with the codec (*.MP4V) on your systems. What you have to do is do a bit of hit and trial at your end.</p><p>Let me help you a bit. Here are a few CODECs you experiment with — *’mp4v’; *’mp4v’; *’MP4V’; *’MJPG’; *’CVID’; *’MSVC’; *’X264’; *’XVID’; with both extension .mp4 or .avi. Once you figure it out, you might just save a lot of time later if you head on a task to save a video using python or OpenCV. If you figure it out early, you’re lucky, otherwise you gotta take the pain bois.</p><p>Lines 9–10 initialize the data that we’ll be feeding to our .csv file. Previous_x and previous_y are basically to make sure if the frame crops off a few joints, the new data will be updated by the previous frame’s data. (I know you’ll go for another read of the last line, but leave it, it doesn’t matter)</p><p>Lines 13–17; the pairs are the pair of joints so that they make a body part, for e.g. the line composed on the shoulder, between the neck joint and the shoulder joint.</p><p>Lines 20–21; thresh is the threshold probability above which the possibility of the occurrence of a joint would be considered. The rest are the colors we want to give to our ‘stick figure’. I might just call it a stick figure in the rest of the article :P</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9bd0686066a79f3419f9228892a9f97/href">https://medium.com/media/c9bd0686066a79f3419f9228892a9f97/href</a></iframe><p>(Here you go, a bigger gist, cuz I am sick of the non-continuous code blocks)</p><p>The first 6 lines above initialize your progressbar, to keep a track on the progress of your, umm, progress. We start the iteration through the frames of the input video on line 9. And the rest is history. JK, nothing special.</p><p>Lines 10–22; We read the frames, we break the loop if there’s no apparent frame (this is really important. Try skipping this part you might lose all your progress at 99% of the progressbar), we preprocess the frame to the compatible format for inputting in the model. Line 18; we input that preprocessed image (inpBlob) to the model, and get the output.</p><p>NOTE: Intelligent Question? The answer is no, we do not change the colorspace from BGR to RGB, since Caffe models themselves accept BGR color!</p><p>The output is a 4-D matrix with:</p><ul><li>The First Dimension being the image id, in case we input multiple images. In our case, it’s a single frame! So not relevant.</li><li>The Second Dimension is the index of a keypoint. The model produces Confidence Maps and Part Affinity maps which are all concatenated. The model that we are using (MPI Model) produces 44 points, and we are interested only in the first 15 points, which correspond to the joints.</li><li>The Third Dimension is the Height of the output map.</li><li>The Fourth Dimension is the Width of the output map.</li></ul><p>On line 30, we find the location (coordinates) of the key points by finding the maxima in the output map of that key point. Following that we readjust the coordinates depending on the output we need on the lines 31 &amp; 32 and append the coordinates to a list which will be fed to the output CSV file later.</p><p>Lines 43–48; we compose the circles on the frame at the location of every output coordinate received, and insert the lines to create the stick figure! Lines 50–54 write the frame to the output video location.</p><p>This while loop takes a little time to complete depending on the computation of your system. The progress bar gives you an idea of by when the loop will end, you might go out, have a round of beer and come back.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F460757830%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F460757830&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F962263535_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a011c450e9a0bea7ae1dc457005d76f/href">https://medium.com/media/4a011c450e9a0bea7ae1dc457005d76f/href</a></iframe><p>In the end, lines 68–71 feed the data collected through the whole iteration into a single .csv file. Now, this is an important step in order to get a cleaner output using the next code, that is, clean_output.py.</p><h4>Get a cleaner output</h4><p>Bored? Well, this part might be an important value addition to what you’ve already obtained. Let’s move on to understand what clean_output.py!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff04dbdf298d7040587c9b718814f142/href">https://medium.com/media/ff04dbdf298d7040587c9b718814f142/href</a></iframe><p>The first eight lines import the essential libraries that we need. Note that, we will be centrally using the Signal module’s (Line 2) Savgol Filter to smoothen the .csv file that we obtained in the last part. (See Lines 17–19)</p><p>The window size parameter (window_length) specifies how many data points will be used to fit a polynomial regression function. The second parameter specifies the degree of the fitted polynomial function (if we choose 1 as the polynomial degree, we end up using a linear regression function).</p><p>In every window, a new polynomial is fitted, which gives us the effect of smoothing the input data. To understand more on how Savgol Function works, check this <a href="https://www.mikulskibartosz.name/smoothing-time-series-in-python-using-savitzky-golay-filter/">link</a> out.</p><p>Another problem with raw pose estimation models (especially Open Pose) is that the coordinates reflect themselves within frames and that sometimes give a very, umm, non-aesthetic experience. To solve that, we define the next code block.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1f61b120c4b8c42acfc2907d3d35e4ac/href">https://medium.com/media/1f61b120c4b8c42acfc2907d3d35e4ac/href</a></iframe><p>The block above essentially takes a reference from the shoulders of the person in the frame, and analyses if the left shoulder is on the left side of the frame, and right is on the right. If it’s otherwise, all the points reflect back to their original positions. Pretty simple, and effective!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/632c8b80a2b6e55415362feda1c64414/href">https://medium.com/media/632c8b80a2b6e55415362feda1c64414/href</a></iframe><p>The above code block is more or less similar to the one in open_pose.py, where we initialize the video capturing, save the specifics in some variables, initialize the writer, etc.</p><blockquote>NOTE AGAIN! Please use the CODEC and the Extension pair specific to your systems, as I explained before!</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4d70a51e69a24ffefde4fdd129f053c/href">https://medium.com/media/e4d70a51e69a24ffefde4fdd129f053c/href</a></iframe><p>Now finally, the moment you’ve been waiting for (hopefully not) the last code block is here!</p><p>Needless to explain I guess, this one iterates through the input video (apparently the same as before) and composes the cleaned up points on each frame, iteratively!</p><p>And you open the outputs directory, and there you see the results!</p><p>This is the difference between what you got before and what you get now...</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F460759376%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F460759376&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F962263547_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/2dc1c72f4fb7c329e3ccc01705219d07/href">https://medium.com/media/2dc1c72f4fb7c329e3ccc01705219d07/href</a></iframe><p>Do you see the difference? The left video is the unclean output by the raw pose estimation model, and the right one is the output after applying the Savgol function. I get it, this is not real-time. But nevertheless, it’s efficient for building simple applications!</p><p>Won’t give much of an Outro, since the post has already been pretty long, but if you like this tutorial, I’d definitely keep my next one on how to make a simple jump rope application I demonstrated above!</p><p>Let me know how you like it with the responses and your comments! (First try so need some motivation guys, TBH).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d239cc33fe6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>