<?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 Chandana Rajeev on Medium]]></title>
        <description><![CDATA[Stories by Chandana Rajeev on Medium]]></description>
        <link>https://medium.com/@chandanarajiv01?source=rss-9d89ab8b31a9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*W5X205i0dYwDuKUILZh5kw.png</url>
            <title>Stories by Chandana Rajeev on Medium</title>
            <link>https://medium.com/@chandanarajiv01?source=rss-9d89ab8b31a9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 02:28:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chandanarajiv01/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[Zero-Shot Defect Detection with Gemini: Prompt Engineering Tips to Improve Accuracy]]></title>
            <link>https://medium.com/@chandanarajiv01/zero-shot-defect-detection-with-gemini-prompt-engineering-tips-to-improve-accuracy-e020b0c9ec53?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e020b0c9ec53</guid>
            <category><![CDATA[zero-shot]]></category>
            <category><![CDATA[image-annotation]]></category>
            <category><![CDATA[object-detection]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[google-gemini-flash]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Tue, 15 Sep 2026 12:29:16 GMT</pubDate>
            <atom:updated>2026-09-15T12:29:16.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8a6QzLhKu8sKlAQ2" /></figure><p>Zero-shot detection means that we provide <strong>zero image examples</strong> to the model. Instead, using only a well-defined prompt, we ask the model to <strong>identify and classify defects</strong> present in an image.</p><p>The model then returns the <strong>bounding box of the detected defect</strong>, along with the defect classification based on the instructions provided in the prompt.</p><p>This application can be very useful for <strong>speeding up the annotation process</strong>, especially when dealing with large volumes of images. It can reduce the amount of manual effort required and help annotators focus more on reviewing and validating the model’s predictions.</p><p>The quality of the results, however, depends heavily on how the prompt is designed. Through experimentation with the Gemini model, I found a few prompting techniques that helped improve detection accuracy.</p><h3>Prompting Tips for Improving Detection Accuracy</h3><p>I will share some of the prompting tips that helped improve the detection accuracy of the Gemini model:</p><ul><li><strong>Use the Gemini API instead of the web chat</strong> when experimenting with prompts and extracting keywords. The API provides a more consistent environment for testing and integrating the model into an application.</li><li><strong>Start with a vague question</strong> to understand what the model observes first. For example, ask: <strong>“What do you see?”</strong> This helps identify the basic information the model is able to recognize from the image.</li><li>The model may provide information such as <strong>product identification, shape, colour, structure, and other visual characteristics</strong>. These details can be used to create a <strong>product summary</strong>, which can then be included as part of the prompt.</li><li><strong>Provide a concise and straightforward definition of the defect</strong> you want the model to detect. Avoid using uncertain words such as <em>“likely,” “mostly,” “sometimes,”</em> etc., as these can make the defect definition ambiguous.</li><li>Use prompt “Do you notice any anomaly to know the keywords that helps model to detect the defect?”</li><li><strong>Clearly specify the expected output format.</strong> For example, define exactly how the model should return the defect name, confidence, and bounding box coordinates. A structured output makes the results easier to process programmatically.</li><li>Gemini returns bounding box coordinates in the format <strong>[ymin, xmin, ymax, xmax]</strong>, with coordinates normalized to a range of <strong>0–1000</strong> and the origin at the top-left corner of the image. Here, <strong>ymin and ymax</strong> represent the top and bottom boundaries, while <strong>xmin and xmax</strong> represent the left and right boundaries of the defect. If your annotation tool expects <strong>[xmin, ymin, xmax, ymax]</strong>, you need to reorder Gemini’s coordinates accordingly.</li><li><strong>Avoid negative prompts</strong> wherever possible. Instead of telling the model what <em>not</em> to detect, clearly describe what the target defect looks like and what characteristics it should have.</li><li><strong>Keep the defect definition and the image characteristics consistent.</strong> The terminology used in the prompt should match what is actually visible in the image. For example, if a black spot is present but the prompt describes it as rust while the model interprets it as grease, the model may classify the defect incorrectly.</li><li><strong>Be specific about the visual characteristics of the defect.</strong> Including details such as colour, shape, texture, location, and appearance can help the model distinguish between visually similar defects.</li><li><strong>Keep the prompt simple and focused.</strong> Adding too many unnecessary instructions can sometimes make it harder for the model to identify the actual objective.</li></ul><p>Overall, <strong>prompt engineering plays an important role in zero-shot defect detection</strong>. A clear defect definition, consistent terminology, and well-structured output requirements can significantly improve the quality and reliability of the model’s predictions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e020b0c9ec53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is nlohmann]]></title>
            <link>https://medium.com/@chandanarajiv01/what-is-nlohmann-9e6f3da6b81d?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/9e6f3da6b81d</guid>
            <category><![CDATA[json]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[c-programming]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Mon, 06 Jul 2026 10:31:26 GMT</pubDate>
            <atom:updated>2026-07-06T10:31:26.870Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*lUUj9a1A0H90aVbS-3iZAg.png" /></figure><p>Imagine two people trying to work together:</p><ol><li><strong>The Internet (which speaks JSON):</strong> JSON is simply a standardized way to write down information so that computers can easily share it. Think of it like a universal, digital packing slip. It looks something like this: <em>Name: John, Age: 30, Active: Yes.</em></li><li><strong>A C++ Program (which speaks C++):</strong> C++ is an incredibly fast and powerful programming language, but it is also very strict and rigid. It doesn’t naturally understand those simple “packing slips.”</li></ol><p>Historically, getting a strict C++ program to read or write a flexible JSON packing slip was a frustrating, complicated chore. It was like hiring a very strict accountant who refuses to read any document unless it’s formatted exactly to their hyper-specific standards.</p><p><strong>nlohmann</strong> (named after its creator, Niels Lohmann) is essentially a brilliant, plug-and-play translator that sits between the C++ program and the JSON packing slips.</p><p>example</p><pre>{<br> &quot;name&quot;: &quot;Alice&quot;,<br> &quot;age&quot;: 28,<br> &quot;has_pets&quot;: true<br>}</pre><h3>2. The C++ Program (Using the Translator)</h3><p>Here is how a programmer uses <strong>nlohmann</strong> to make C++ understand that information without breaking a sweat. I have numbered the steps in the code so we walk through them below.</p><pre>#include &lt;iostream&gt;<br>// Step 1: Bring in the translator<br>#include &lt;nlohmann/json.hpp&gt;<br><br>// Give the translator a shorter nickname to save typing<br>using json = nlohmann::json;<br><br>int main() {<br>    <br>    // Step 2: Hand the packing slip to the translator<br>    // (In a real program, this might be downloaded from the internet)<br>    json packing_slip = R&quot;(<br>        {<br>          &quot;name&quot;: &quot;Alice&quot;,<br>          &quot;age&quot;: 28,<br>          &quot;has_pets&quot;: true<br>        }<br>    )&quot;_json;<br><br>    // Step 3: Ask the translator for specific information<br>    std::string user_name = packing_slip[&quot;name&quot;];<br>    int user_age = packing_slip[&quot;age&quot;];<br><br>    // Step 4: Have C++ use the translated information!<br>    std::cout &lt;&lt; &quot;Hello, &quot; &lt;&lt; user_name &lt;&lt; &quot;! &quot;;<br>    std::cout &lt;&lt; &quot;You are &quot; &lt;&lt; user_age &lt;&lt; &quot; years old.\n&quot;;<br><br>    return 0;<br>}</pre><ul><li><strong>Step 1:</strong> The programmer includes the nlohmann file. This is the equivalent of hiring the translator and bringing them into the room.</li><li><strong>Step 2:</strong> We feed the raw, text-based JSON data into a special container called json. The translator instantly reads the text, organizes it, and prepares it for C++.</li><li><strong>Step 3 (The Magic Step):</strong> This is why programmers love nlohmann. Notice how we just ask for packing_slip[&quot;name&quot;]? Before nlohmann existed, finding the word &quot;name&quot; in that text and extracting &quot;Alice&quot; safely required writing a lot of tedious, error-prone code. Nlohmann makes it as easy as looking up a word in a dictionary.</li><li><strong>Step 4:</strong> C++ now has the data in its own strict, native format (a std::string for the word &quot;Alice&quot; and an int for the number 28) and can happily print it to the screen.</li></ul><p>In short, nlohmann took a block of raw text and seamlessly handed the exact values over to C++ in a language it could immediately understand.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9e6f3da6b81d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Perform Camera Calibration Using OpenCV and Python]]></title>
            <link>https://medium.com/@chandanarajiv01/camera-calibration-7792e7c4a7fb?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7792e7c4a7fb</guid>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[camera-calibration]]></category>
            <category><![CDATA[calibration]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Tue, 10 Feb 2026 15:00:06 GMT</pubDate>
            <atom:updated>2026-02-10T15:51:45.038Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/495/0*sAjJs_9WQfdU1vs5.gif" /></figure><p>What is calibration?</p><p>Calibration is the process of determining the relationship between the measured output of a system and the true physical quantity it represents, in order to correct systematic errors.</p><p>What is camera calibration?</p><p>We do camera calibration to get all parameters required to determine a relationship between a 3D point in the world coordinate to its 2D pixel coordinate.</p><p>What is this info we need?</p><p>Extrinsic parameters describe the position and orientation of the camera in the world coordinate system.</p><p>Intrinsic parameters describe the internal geometry and optical characteristics of the camera.</p><p>It all originated from how does a 3D point project onto a 2D plane through a pinhole.</p><p>Imagine a simple pinhole camera:</p><ul><li>A tiny hole at the origin (0,0,0)</li><li>An image plane placed at distance <strong>f</strong> in front of it</li><li>A 3D point in space: (X,Y,Z)</li></ul><p>Now imagine a straight line from the 3D point to the pinhole.</p><p>That line continues until it hits the image plane.</p><p>Where it hits the image plane — that is the image of the point.</p><p>You have two similar triangles:</p><p>Large triangle:</p><ul><li>Height = X</li><li>Depth = Z</li></ul><p>Small triangle:</p><ul><li>Height = x (on image plane)</li><li>Depth = f</li></ul><p>Because triangles are similar:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*e6VuYo2owITJx22WdmQXJg.png" /></figure><ul><li>f is the focal length.</li><li>Z is the depth (distance from the camera)</li><li>Note the division by Z: This creates the <strong>perspective effect</strong> (objects further away look smaller).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*1eV2dZKaQ8ZAsKeOxvid_w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*vXzHclicvYC_xpqFKrhhmA.png" /></figure><p>How to do camera calibration with opencv ?</p><p>OpenCV calibration requires a planar pattern (like a chessboard).</p><p>Because the board is flat, we can define the <strong>World Coordinate System</strong> such that the board lies on the Z=0 plane.</p><p>So, every point on the chessboard has coordinates (X, Y, 0).</p><pre>import numpy as np<br>import cv2<br>import glob<br><br># --- CONFIGURATION ---<br>CHECKERBOARD = (9, 6) # (columns, rows) of internal corners<br>SQUARE_SIZE = 20.0    # Physical size of one square (e.g., 20mm)<br><br># --- 1. PREPARE OBJECT POINTS (World Coordinates) ---<br># We want an array of coordinates: (0,0,0), (1,0,0), (2,0,0) ... (8,5,0)<br># This corresponds to the corners on the printed board.<br><br># Create an array of zeros for 3D points (x, y, z)<br># Shape: (Number_of_corners, 3) -&gt; (54, 3)<br>objp = np.zeros((CHECKERBOARD[0] * CHECKERBOARD[1], 3), np.float32)<br><br># Generate grid coordinates using np.mgrid<br># .T translates it, .reshape(-1, 2) flattens it to a list of (x, y) pairs<br>grid = np.mgrid[0:CHECKERBOARD[0], 0:CHECKERBOARD[1]].T.reshape(-1, 2)<br><br># Assign grid to x and y columns of objp, and scale by square size<br>objp[:, :2] = grid * SQUARE_SIZE<br><br># Arrays to store object points and image points from all the images.<br>objpoints = [] # 3d point in real world space<br>imgpoints = [] # 2d points in image plane.<br><br># --- 2. LOAD IMAGES ---<br># Make sure your images are in the current directory or provide path<br>images = glob.glob(&#39;*.jpg&#39;) <br><br>if not images:<br>    print(&quot;No images found! Make sure you have &#39;calibration*.jpg&#39; files.&quot;)<br>    exit()<br><br>print(f&quot;Found {len(images)} images. Processing...&quot;)<br><br>for fname in images:<br>    img = cv2.imread(fname)<br>    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br><br>    # Find the chess board corners<br>    # ret is True if corners are found<br>    ret, corners = cv2.findChessboardCorners(gray, CHECKERBOARD, None)<br><br>    if ret == True:<br>        print(f&quot;Corners found in {fname}&quot;)<br>        <br>        # Refine corner locations (Sub-pixel accuracy)<br>        # This makes calibration much more accurate<br>        corners2 = cv2.cornerSubPix(<br>            gray, corners, (11,11), (-1,-1), <br>            (cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER, 30, 0.001)<br>        )<br><br>        objpoints.append(objp)<br>        imgpoints.append(corners2)<br><br>        # Optional: Draw and display the corners<br>        # cv2.drawChessboardCorners(img, CHECKERBOARD, corners2, ret)<br>        # cv2.imshow(&#39;img&#39;, img)<br>        # cv2.waitKey(100)<br>    else:<br>        print(f&quot;Could not find corners in {fname}&quot;)<br><br>cv2.destroyAllWindows()<br><br># --- 3. CALIBRATION ---<br># This is the heavy lifting function.<br># It solves for K (mtx) and distortion (dist), plus Extrinsics (rvecs, tvecs)<br>ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(<br>    objpoints, imgpoints, gray.shape[::-1], None, None<br>)<br><br># --- 4. RESULTS ---<br>print(&quot;\n-------------------------------------------&quot;)<br>print(f&quot;Reprojection Error (RMS): {ret:.4f} pixels&quot;)<br>print(&quot;(Lower is better. &lt; 1.0 is good, &lt; 0.1 is excellent)&quot;)<br>print(&quot;-------------------------------------------&quot;)<br><br>print(&quot;\nCamera Matrix (Intrinsics K):\n&quot;)<br>print(mtx)<br><br>print(&quot;\nDistortion Coefficients (k1, k2, p1, p2, k3):\n&quot;)<br>print(dist)<br><br># --- 5. UNDISTORTION (Test) ---<br># Take the last image and undistort it to see the result<br>img = cv2.imread(images[0])<br>h,  w = img.shape[:2]<br><br># Get optimal new camera matrix (removes black edges if any)<br>newcameramtx, roi = cv2.getOptimalNewCameraMatrix(mtx, dist, (w,h), 1, (w,h))<br><br># undistort<br>dst = cv2.undistort(img, mtx, dist, None, newcameramtx)<br><br># crop the image (optional, based on roi)<br>x, y, w, h = roi<br>dst = dst[y:y+h, x:x+w]<br><br>cv2.imwrite(&#39;calibresult.png&#39;, dst)<br>print(&quot;\nSaved undistorted image to &#39;calibresult.png&#39;&quot;)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7792e7c4a7fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A look back at social media: how it has affected our lives]]></title>
            <link>https://medium.com/@chandanarajiv01/a-look-back-at-social-media-how-it-has-affected-our-lives-bd66b80fb350?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd66b80fb350</guid>
            <category><![CDATA[phone-addiction]]></category>
            <category><![CDATA[brain]]></category>
            <category><![CDATA[digital-awareness]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[cell-phone-addiction]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 04:27:50 GMT</pubDate>
            <atom:updated>2026-01-20T04:27:50.389Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j2y-KeljvY5xNRTq.jpg" /></figure><p>We can’t miss out a day checking our social media pages and it has now become one of the best mediums to share information within seconds. Social media can be a breeding ground for negative energy, but the magic of social media is that sometimes extremely beautiful things come out of it.</p><p>We love social media because it is all about connecting with people and whether it be to stay in touch with family members who are across the country or supporting your internet bestie, staying in contact with people is the greatest asset of social media. Being able to express ourselves is why Instagram rocketed. People now put hashtags to everything they want to share.</p><p>Many feel comfortable in their self-identity, they may be timid in person but more alive and free online. They can find a tribe who love and identify alongside them. Millions of people do not have access to a free press in their countries of residence. Given that all major news agencies have social media accounts, apps like Facebook, Instagram and Twitter give those people a way to stay updated with news reports around the world.</p><p>At its core social media is fun. Games, chats, interesting articles, memes and videos. There is plenty of content to keep you entertained for hours. You can create your content and share it on social media pages and gain followers. In this way, many online businesses have taken bloom. Social media is also the best tool for marketing since millions of people are connected on the same platform.</p><p>One of the worst drawbacks of social media is cyberbullying. It has become very easy to sit behind a screen and throw harsh comments at people. Victims of cyberbullying are prone to depression, anxiety and other psychological problems. FOMO — fear of missing out has become a common theme, and often leads to continual checking of social media sites. The fear of not regularly checking can affect your mental health.</p><p>People are bombarded with information and it reduces the ability to focus on one at a time. Most of this information however is irrelevant and they may be fishing messages. They can get access to your private information such as passwords and card details.</p><p>Oversharing on social sites can put your privacy at risk. We should think twice before uploading anything. Whether it may hurt anyone or is a piece of useful information to share.</p><p>Social media is a double-sided coin. We have to use this amazing tool diligently. We have to be in control of our social sites rather than social sites taking away our control.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd66b80fb350" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I finally understood how a transistor works]]></title>
            <link>https://medium.com/@chandanarajiv01/i-finally-understood-how-a-transistor-works-32635494e4b9?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/32635494e4b9</guid>
            <category><![CDATA[electronics]]></category>
            <category><![CDATA[mosfet]]></category>
            <category><![CDATA[practical]]></category>
            <category><![CDATA[transistor]]></category>
            <category><![CDATA[circuit-design]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Wed, 14 Jan 2026 09:29:42 GMT</pubDate>
            <atom:updated>2026-01-14T09:29:42.924Z</atom:updated>
            <content:encoded><![CDATA[<p>forget the waterfalls and plumbing analogies.</p><p>reference link — <a href="https://www.build-electronic-circuits.com/how-transistors-work/">https://www.build-electronic-circuits.com/how-transistors-work/</a></p><h4>1. What Does a Transistor Actually Do?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/243/1*ofoibvXAS5JKKQo3y6i1dA.png" /></figure><p>At its simplest, a transistor works like an <strong>electronic switch</strong>.<br> It can turn current <strong>ON</strong> or <strong>OFF</strong> — similar to a relay — but with one major advantage:</p><blockquote><strong><em>A transistor has no moving parts.</em></strong></blockquote><p>Because of this, transistors are:</p><ul><li>Faster than relays, Smaller, More reliable</li><li>Able to do something relays cannot: <strong>operate partially ON</strong></li></ul><p>That last point is crucial. Unlike a mechanical switch that is either open or closed, a transistor can sit anywhere between fully ON and fully OFF. This “in-between” behavior is what allows transistors to act as <strong>amplifiers</strong>, not just switches.</p><h4>2. How does a Transistor function?</h4><p>One of the oldest and most widely taught transistor types is the <strong>Bipolar Junction Transistor</strong>, or <strong>BJT</strong>. A common example is the <strong>NPN transistor</strong>.</p><h3>The Three Terminals of an NPN Transistor</h3><p>An NPN transistor has three pins:</p><ul><li><strong>Base (B)</strong> — the control input</li><li><strong>Collector ©</strong> — where current enters</li><li><strong>Emitter (E)</strong> — where current exits</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*jaRhwobiwq4PXMthbowuRw.png" /></figure><p>If you turn it ON, current can flow through it from the collector to the emitter. When it’s OFF, no current can flow.</p><p>To turn the transistor <strong>ON</strong>, you must apply a voltage between the <strong>base and emitter</strong>.</p><p>Specifically, you need to apply a voltage of roughly <strong>0.7V</strong> between the base and the emitter.</p><p>Why 0.7V? The internal structure of the base-to-emitter path behaves exactly like a <strong>diode</strong>. Just as a diode needs a certain “forward voltage” to let electricity pass, the transistor won’t wake up until that threshold is met.</p><p>In the example circuit below, the transistor is OFF. That means no current can flow through it, so the <a href="https://www.build-electronic-circuits.com/what-is-an-led/">Light-Emitting Diode (LED)</a> is also off. To turn the transistor ON, you need a voltage of about 0.7V between the base and the emitter. If you had a 0.7V battery, you could have connected it between the base and emitter, and the transistor would have turned ON.</p><p>Because most batteries (like 9V batteries) provide much more than 0.7V, we use a <strong>resistor</strong> in series with the base. This resistor “soaks up” the extra voltage, ensuring the base gets exactly what it needs without burning out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*GpaCbpYILq2IFrJPnU-4vw.png" /></figure><p>If you also add a pushbutton, you can control the transistor, and thereby the LED, ON and OFF with a button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*3pNhR5zW87yLXKyyFsYEUQ.png" /></figure><p>When a small current flows into the <strong>base</strong>, the transistor allows a much larger current to flow from <strong>collector to emitter</strong>. The ratio between these two currents is called the <strong>current gain</strong>, often written as <strong>β (beta)</strong> or <strong>hFE</strong>.</p><p>For common transistors like:</p><ul><li>BC547</li><li>2N3904</li></ul><p>The gain might be around <strong>100</strong>.</p><p>That means:</p><ul><li>0.1 mA into the base</li><li>Can allow ~10 mA through the collector</li></ul><p>This property lets tiny control signals operate much larger loads.</p><p>Suppose:</p><ul><li>Supply voltage = 9 V</li><li>Base–emitter voltage ≈ 0.7 V</li><li>Desired base current = 0.1 mA</li></ul><p>The resistor sees:</p><p>9V−0.7V=8.3V</p><p>Using Ohm’s Law:</p><p>R=VI=8.30.0001=83 kΩ</p><p>Since 83 kΩ is not a standard value, <strong>82 kΩ</strong> works perfectly.</p><p>The resistor on the LED side is chosen independently — exactly as if the LED were connected directly to the supply.</p><p>When selecting a BJT, the most important specification is:</p><ul><li><strong>Collector current (IC max)</strong></li></ul><p>This tells you how much current the transistor can safely handle. Always choose a transistor rated higher than your expected load current.</p><h4>MOSFET</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*nOeDFrVtQajcQcdhac0sTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/202/1*E8DkeTc-DwjpCJ4pz_aQoA.png" /></figure><p>While the BJT uses a physical flow of electrons to open its gate, the <strong>MOSFET</strong> uses an invisible electric field. This is why it’s called a “Field-Effect” transistor.</p><p>The <strong>Gate</strong> of a MOSFET is electrically insulated. No current actually flows <em>into</em> it. Instead, when you apply voltage to the Gate, it creates an electric field that attracts charge carriers to form a “bridge” (a channel) between the <strong>Drain</strong> and the <strong>Source</strong>.</p><p>It is the most common transistor found in computers today.</p><p>Its pins are named differently:</p><ul><li><strong>Gate (g):</strong> The control pin.</li><li><strong>Drain (d):</strong> Where current enters.</li><li><strong>Source (s):</strong> Where current exits.</li></ul><p>To turn on an N-channel MOSFET, you apply a voltage between the <strong>gate and source</strong> that exceeds the <strong>threshold voltage (VGS(th))</strong>.</p><p>Threshold voltage does NOT mean fully ON.</p><p>It only means the transistor <em>just begins</em> to conduct a very small current.</p><p>To carry meaningful current (like driving an LED), the gate voltage must be <strong>well above</strong> the threshold.</p><p>The gate of a MOSFET behaves like a <strong>capacitor</strong>.</p><p>Once charged, it stays charged — even if the control signal is removed. Without a discharge path, the MOSFET may remain ON unintentionally.</p><p>A <strong>pull-down resistor</strong> provides a safe path for the gate charge to drain, ensuring the MOSFET reliably turns OFF.</p><p>Although MOSFET gates draw no steady current, charging the gate capacitance causes a brief current spike.</p><p>A <strong>gate resistor</strong>:</p><ul><li>Limits this spike</li><li>Protects microcontroller pins</li><li>Reduces ringing and EMI</li></ul><p>Values between <strong>100 Ω and 1 kΩ</strong> are commonly used.</p><p>Why not connect a load directly to a microcontroller pin?</p><p>Because:</p><ul><li>Microcontroller pins provide limited current</li><li>Loads like motors, LEDs, relays, and speakers require much more</li></ul><p>A transistor allows:</p><ul><li>A <strong>small signal</strong> to control a <strong>large load</strong></li><li>Low-voltage logic to control high-voltage systems</li></ul><p>This is why transistors are used everywhere — from relays to motor drivers to power supplies.</p><h4>Amplification</h4><p>A transistor doesn’t have to be just “On” or “Off.” It operates in three distinct zones:</p><ol><li><strong>Cut-off (OFF):</strong> No base current/voltage. The switch is open.</li><li><strong>Saturation (Fully ON):</strong> You’ve pushed the base so hard that the main channel is flowing at its absolute maximum capacity.</li><li><strong>Active Region (The Dimmer):</strong> This is the “sweet spot” used for <strong>Amplification</strong>.</li></ol><p>In the <strong>Active Region</strong>, if your input signal (like music) fluctuates slightly, the transistor causes the large output current to fluctuate in the exact same pattern. It creates a “giant version” of the tiny input wave. This is how a smartphone’s tiny electrical signal becomes loud enough to vibrate a speaker cone.</p><p>When operated in the <strong>linear region</strong>, a transistor can produce a larger copy of a small input signal. A changing input voltage creates a changing current through a load (like a speaker), converting electrical signals into sound. This is the foundation of: Audio amplifiers, Sensor signal conditioning, Analog circuits.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32635494e4b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Image handling in computer vision]]></title>
            <link>https://medium.com/@chandanarajiv01/image-handling-in-computer-vision-71be1f5f6eeb?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/71be1f5f6eeb</guid>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Fri, 02 Jan 2026 07:57:30 GMT</pubDate>
            <atom:updated>2026-01-02T07:57:30.197Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0cm0y4TXq1sS8OMe" /></figure><p>For a long period of time I had difficulty in understanding the methods to handle images for different image processing algorithms.</p><p>So this is an effort to learn about how to take images as input, save the result image as output etc.</p><p>first lets look into types of <strong>image-reading libraries</strong>, what they are good at, and <em>when you should prefer them</em></p><h3>PIL</h3><pre>from PIL import Image<br>img = Image.open(&quot;image.png&quot;)</pre><h4>Supports</h4><ul><li>JPEG, PNG, TIFF, BMP, WebP</li><li>EXIF metadata</li><li>8-bit and limited 16-bit</li></ul><p>imageio</p><pre># import library<br>import imageio.v3 as iio<br><br># read an image<br>image = iio.imread(&#39;testa.png&#39;)<br><br># print shape of the image<br>print(image.shape)</pre><p>scikit-image</p><pre>from skimage import io<br>img = io.imread(&quot;image.tiff&quot;)</pre><p>rawpy</p><pre>import rawpy<br><br>with rawpy.imread(&quot;image.CR2&quot;) as raw:<br>    raw_img = raw.raw_image.copy()</pre><p>tifffile</p><pre>import tifffile as tiff<br>img = tiff.imread(&quot;image.tiff&quot;)</pre><p>OpenEXR + Imath</p><pre>import OpenEXR, Imath, numpy as np</pre><p>matplotlib</p><pre>import matplotlib.pyplot as plt<br>img = plt.imread(&quot;image.png&quot;)</pre><h3>OpenCV</h3><p><strong>read a single image</strong></p><pre>#reading a single image<br>import cv2<br><br>img = cv2.imread(&quot;image&quot;)</pre><ol><li>filename (Required) — The name or full path of the image file.</li></ol><ul><li>If your coding file (script) and image file are in the same directory, you only need to specify the image name along with its extension (e.g., “image.png” or “photo.jpg”).</li><li>If they are in different folders, you must provide the full path to the image file.</li></ul><p>Example path format:</p><p>“C:/Users/ssabb/Downloads/Astronaut.png”</p><p>Avoid spaces in filenames, folder names, or image names, as they may cause errors. Use forward slashes (/) instead of backslashes (\) in file paths to ensure compatibility across different operating systems. We can also use a relative path instead of an absolute path when specifying the image file location.</p><p>2. flags (Optional) — This argument determines how the image should be loaded. OpenCV provides several options:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GF0tQtAzE2ZVxBE3zt2d7Q.png" /></figure><p>If no flag is specified, imread() loads the image in BGR format by default, which means it reads the image as a 3-channel color image while ignoring any alpha (transparency) channel. This is equivalent to using IMREAD_COLOR (or 1).</p><p>cv2.imshow(window name, image)</p><p># Wait for a key press before closing the window</p><p>cv2.waitKey(0)</p><p>cv2.destroyAllWindows()</p><ol><li>window name (Required) — A string representing the name of the window where the image will be displayed.</li><li>image (Required) — The image array that was read using cv2.imread().</li></ol><p>imshow(“Displayed Image”, image) — Opens a new window with the title “Displayed Image” and displays the loaded image.</p><p>waitKey(0) — Pauses the program execution until a key is pressed. Without this, the image window may open and close instantly. You can also specify a time (in milliseconds). For example, waitKey(5000) will keep the window open for 5 seconds before closing it automatically.</p><p>Setting waitKey(0) does not mean the window remains open for 0 milliseconds — instead, it tells OpenCV to keep the window open until the user presses a key, making it the preferred option for manual image inspection.</p><p>Reading mulitple images</p><p>OpenCV <strong>never reads “multiple images” by itself</strong>.</p><p>You always do this pattern:</p><pre>get list of image paths → loop → cv.imread(path)</pre><p>So the problem reduces to:<br> 👉 <em>How do I get multiple image file paths?</em></p><h3>Using glob</h3><pre>import cv2 as cv<br>import glob<br><br>image_paths = glob.glob(&quot;images/*.jpg&quot;)<br><br>images = []<br>for path in image_paths:<br>    img = cv.imread(path)<br>    images.append(img)</pre><h3>Using os</h3><pre>import os<br>import cv2 as cv<br><br>folder = &quot;images&quot;<br>images = []<br><br>for filename in os.listdir(folder):<br>    if filename.endswith(&quot;.jpg&quot;):<br>        img = cv.imread(os.path.join(folder, filename))<br>        images.append(img)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71be1f5f6eeb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How digital image formation works]]></title>
            <link>https://medium.com/@chandanarajiv01/how-digital-image-formation-works-c72f2a99b251?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c72f2a99b251</guid>
            <category><![CDATA[digital-image-processing]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[image-processing]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 11:00:14 GMT</pubDate>
            <atom:updated>2025-12-15T11:00:14.757Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/0*BDmGChMXIOBvBI-Y.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*59p3Pj7aAI7fG_Sf1udTfQ.png" /></figure><p>The value of f at spatial coordinates (x ,y ) is a scalar quantity whose physical meaning is determined by the source of the image, and whose values are proportional to energy radiated by a physical source (e.g., electromagnetic waves).</p><p>Function f (x ,y ) is characterized by two components:</p><p>(1) the amount of source illumination incident on the scene being viewed.</p><p>(2) the amount of illumination reflected by the objects in the scene.</p><p>Appropriately, these are called the illumination and reflectance components, and are denoted by i (x ,y ) and r (x,y) two functions combine as a product to form</p><p>f (x ,y ): = i(x,y) * r(x,y)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*oXiH_3M_cbse3iz5jxepeQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*TZ0E4HXNHRNaM3n0_LKhbw.png" /></figure><p>To create a digital image, we need to convert the continuous sensed data into a digital format. This requires two processes: sampling and quantization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yVV4xXteL2_oUNiVQxiHOg.png" /></figure><p>The one-dimensional function in Fig. 2.16(b) is a plot of amplitude (intensity level) values of the continuous image along the line segment AB in Fig. 2.16(a). The random variations are due to image noise.</p><p>To sample this function, we take equally spaced samples along line AB, as shown in Fig. 2.16(c).</p><p>The samples are shown as small dark squares superimposed on the function, and their (discrete) spatial locations are indicated by corresponding tick marks in the bottom of the figure.</p><p>The set of dark squares constitute the sampled function. However, the values of the samples still span (vertically) a continuous range of intensity values.</p><p>In order to form a digital function, the intensity values also must be converted (quantized) into discrete quantities.</p><p>The vertical gray bar in Fig. 2.16(c) depicts the intensity scale divided into eight discrete intervals, ranging from black to white.</p><p>The vertical tick marks indicate the specific value assigned to each of the eight intensity intervals.</p><p>The continuous intensity levels are quantized by assigning one of the eight values to each sample, depending on the vertical proximity of a sample to a vertical tick mark.</p><p>The digital samples resulting from both sampling and quantization are shown as white squares in Fig. 2.16(d).</p><p>Starting at the top of the continuous image and carrying out this procedure downward, line by line, produces a two-dimensional digital image. It is implied in Fig. 2.16 that, in addition to the number of discrete levels used, the accuracy achieved in quantization is highly dependent on the noise content of the sampled signal.</p><p>When a sensing strip is used for image acquisition, the number of sensors in the strip establishes the samples in the resulting image in one direction, and mechanical motion establishes the number of samples in the other.</p><p>When a sensing array is used for image acquisition, no motion is required. The number of sensors in the array establishes the limits of sampling in both directions. Quantization of the sensor outputs is as explained above. Figure 2.17 illustrates this concept. Figure 2.17(a)</p><p>The section of the real plane spanned by the coordinates of an image is called the spatial domain, with x and y being referred to as spatial variables or spatial coordinates.</p><p>Array (matrix) composed of the numerical values of f (x ,y ). This is the representation used for computer processing. In equation form, we write the representation of an M N* numerical array as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*yuWxGihX9ki-KzMJaLVZvQ.png" /></figure><p>The right side of this equation is a digital image represented as an array of real numbers. Each element of this array is called an image element, picture element, pixel, or pel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJr3f5O0jP1YBZnF6YX_Zw.png" /></figure><p>As Fig. 2.19 shows, we define the origin of an image at the top left corner. This is a convention based on the fact that many image displays (e.g., TV monitors) sweep an image starting at the top left and moving to the right, one row at a time.</p><p>To express sampling and quantization in more formal mathematical terms, let Z and R denote the set of integers and the set of real numbers, respectively.</p><p>The sampling process may be viewed as partitioning the xy-plane into a grid, with the coordinates of the center of each cell in the grid being a pair of elements from the Cartesian product Z2 (also denoted Z x Z ) which, as Hence, f (x,y)is a digital image if x,y are integers from Z2 and f is a function that assigns an intensity value (that is, a real number from the set of real numbers, R) to each distinct pair of coordinates ( x,y ). This functional assignment is the quantization process.</p><p>If the intensity levels also are integers, then R = Z , and a digital image becomes a 2-D function whose coordinates and amplitude values are integers.</p><p>Image digitization requires that decisions be made regarding the values for M, N, and for the number, L, of discrete intensity levels.</p><p>There are no restrictions placed on M and N, other than they have to be positive integers. However, digital storage and quantizing hardware considerations usually lead to the number of intensity lev els, L, being an integer power of two; that is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X3nTRgEsypkUkXcsO2mDbg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c72f2a99b251" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[SOLVED] C++ Code Not Compiling in VS Code — clock_gettime64 Entry Point Not Found Error (GCC 15.2.0]]></title>
            <link>https://medium.com/@chandanarajiv01/solved-c-code-not-compiling-in-vs-code-clock-gettime64-entry-point-not-found-error-gcc-15-2-0-b98ad83f42a2?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b98ad83f42a2</guid>
            <category><![CDATA[msys2]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[bug-fixes]]></category>
            <category><![CDATA[c-language]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Sun, 30 Nov 2025 08:47:49 GMT</pubDate>
            <atom:updated>2025-11-30T08:47:49.044Z</atom:updated>
            <content:encoded><![CDATA[<h3>[SOLVED] C++ Code Not Compiling in VS Code — clock_gettime64 Entry Point Not Found Error (GCC 15.2.0 MSYS2)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/0*hPwTixRllzsFmUTR" /></figure><h3>The Initial Problem</h3><p>I was trying to build my C++ program in Visual Studio Code using Ctrl+Shift+B, but it wasn&#39;t creating the .exe file. The strange thing was that when I clicked the Run button, it built and created the executable perfectly fine. This inconsistency was frustrating, and I suspected it might be a common VS Code configuration issue.</p><p><strong>What I observed:</strong></p><ul><li>Ctrl+Shift+B failed to produce demo.exe</li><li>The Run button worked without any issues</li><li>I was using MSYS2 UCRT64 toolchain with GCC 15.2.0</li><li>No obvious error messages appeared</li></ul><h3>Step 1: Checking My tasks.json Configuration</h3><p>First, I examined my .vscode/tasks.json file to see if there was a configuration problem:</p><pre>{<br>    &quot;version&quot;: &quot;2.0.0&quot;,<br>    &quot;tasks&quot;: [<br>        {<br>            &quot;label&quot;: &quot;Build demo.cpp (debug)&quot;,<br>            &quot;type&quot;: &quot;shell&quot;,<br>            &quot;command&quot;: &quot;C:/msys64/ucrt64/bin/g++.exe&quot;,<br>            &quot;args&quot;: [<br>                &quot;-std=c++17&quot;,<br>                &quot;-Wall&quot;,<br>                &quot;-v&quot;,<br>                &quot;\&quot;${workspaceFolder}/demo.cpp\&quot;&quot;,<br>                &quot;-o&quot;,<br>                &quot;\&quot;${workspaceFolder}/demo.exe\&quot;&quot;<br>            ],<br>            &quot;options&quot;: {<br>                &quot;cwd&quot;: &quot;${workspaceFolder}&quot;<br>            },<br>            &quot;group&quot;: {<br>                &quot;kind&quot;: &quot;build&quot;,<br>                &quot;isDefault&quot;: true<br>            },<br>            &quot;problemMatcher&quot;: []<br>        }<br>    ]<br>}</pre><p>After searching online forums, I learned that the escaped quotes around file paths were wrong. VS Code automatically handles path escaping, so manually adding \&quot; causes issues.</p><p><strong>I fixed it by removing the quotes:</strong></p><pre>&quot;args&quot;: [<br>    &quot;-std=c++17&quot;,<br>    &quot;-Wall&quot;,<br>    &quot;-v&quot;,<br>    &quot;${workspaceFolder}/demo.cpp&quot;,<br>    &quot;-o&quot;,<br>    &quot;${workspaceFolder}/demo.exe&quot;<br>]</pre><p>I thought this would solve it, but I was wrong.</p><h3>Step 2: The Compilation Still Failed</h3><p>After fixing the quotes, I pressed Ctrl+Shift+B again. The output showed:</p><pre>*  Executing task: C:/msys64/ucrt64/bin/g++.exe -std=c++17 -Wall -v D:\Chandana\Practise_work\cpp/demo.cpp -o D:\Chandana\Practise_work\cpp/demo.exe </pre><pre>Using built-in specs.<br>COLLECT_GCC=C:/msys64/ucrt64/bin/g++.exe<br>gcc version 15.2.0 (Rev8, Built by MSYS2 project)<br>...<br>C:/msys64/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/15.2.0/cc1plus.exe -quiet -v ...<br>*  The terminal process terminated with exit code: 1.<br>*  Terminal will be reused by tasks, press any key to close it.</pre><p>The compilation was starting but crashing during the cc1plus.exe phase with exit code 1. There was no clear error message explaining why.</p><h3>Step 3: Testing from Command Line</h3><p>To get more information, I opened Windows Command Prompt and manually ran the compiler:</p><pre>cd D:\Chandana\Practise_work\cpp<br>C:\msys64\ucrt64\bin\g++.exe -std=c++17 -Wall demo.cpp -o demo.exe</pre><p>This time, a popup error appeared!</p><p><strong>Error Dialog:</strong></p><pre>cc1plus.exe - Entry Point Not Found</pre><pre>The procedure entry point clock_gettime64 could not be located in <br>the dynamic link library <br>C:\msys64\ucrt64\bin\..\lib\gcc\x86_64-w64-mingw32\15.2.0\cc1plus.exe</pre><p><strong>Finally, the real issue!</strong> The cc1plus.exe compiler component couldn&#39;t find the clock_gettime64 function in its required DLL.</p><h3>Step 4: Researching the Bug</h3><p>I searched online for “cc1plus.exe clock_gettime64 entry point not found MSYS2” and discovered this was a <strong>known bug in GCC 15.1.0 and 15.2.0</strong>. The issue was that cc1plus.exe was missing a required procedure entry point in its dynamic link library.</p><p><strong>Root cause:</strong> GCC 15.2.0 had a DLL dependency bug where the compiler executable couldn’t locate necessary functions at runtime.</p><h3>Step 5: The Solution — Copying DLLs</h3><p>The forum posts suggested copying all DLL files from the bin directory to the GCC lib directory so that cc1plus.exe could find them.</p><p><strong>I opened Command Prompt as Administrator and ran:</strong></p><pre>cd C:\msys64\ucrt64\bin<br>copy *.dll C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.2.0\</pre><p>This command copied all necessary DLLs to the directory where cc1plus.exe resides, making the dependencies accessible.</p><h3>Step 6: Testing the Build Again</h3><p>After copying the DLLs, I went back to VS Code and pressed Ctrl+Shift+B:</p><pre>*  Executing task: C:/msys64/ucrt64/bin/g++.exe -std=c++17 -Wall -v D:\Chandana\Practise_work\cpp/demo.cpp -o D:\Chandana\Practise_work\cpp/demo.exe </pre><pre>Using built-in specs.<br>COLLECT_GCC=C:/msys64/ucrt64/bin/g++.exe<br>gcc version 15.2.0 (Rev8, Built by MSYS2 project)<br>...<br>GNU C++17 (Rev8, Built by MSYS2 project) version 15.2.0 (x86_64-w64-mingw32)<br>...<br>*  Terminal will be reused by tasks, press any key to close it.</pre><p><strong>Success!</strong> The compilation completed without errors, and demo.exe was created in my project folder.</p><h3>Step 7: The Runtime Problem</h3><p>Now that the build worked, I tried running my program. My demo.cpp contained:</p><pre>#include&lt;bits/stdc++.h&gt;<br>using namespace std;</pre><pre>int main(){<br>    cout &lt;&lt; &quot;Hello, World!&quot; &lt;&lt; endl;<br>    return 0;<br>}</pre><p>I ran it from the terminal:</p><pre>D:\Chandana\Practise_work\cpp&gt;.\demo.exe</pre><p>But instead of seeing “Hello, World!”, I got <strong>another error popup</strong>:</p><pre>demo.exe - Entry Point Not Found</pre><pre>The procedure entry point clock_gettime64 could not be located in <br>the dynamic link library C:\msys64\ucrt64\bin\libstdc++-6.dll</pre><p>The .exe itself was now looking for DLLs at runtime and couldn’t find them!</p><h3>Step 8: Final Fix — Static Linking</h3><p>I learned that I needed to statically link all dependencies into the executable so it wouldn’t need external DLLs.</p><p><strong>I updated my tasks.json to add the </strong><strong>-static flag:</strong></p><pre>{<br>    &quot;version&quot;: &quot;2.0.0&quot;,<br>    &quot;tasks&quot;: [<br>        {<br>            &quot;label&quot;: &quot;Build demo.cpp (debug)&quot;,<br>            &quot;type&quot;: &quot;shell&quot;,<br>            &quot;command&quot;: &quot;C:/msys64/ucrt64/bin/g++.exe&quot;,<br>            &quot;args&quot;: [<br>                &quot;-std=c++17&quot;,<br>                &quot;-Wall&quot;,<br>                &quot;-static&quot;,<br>                &quot;${workspaceFolder}/demo.cpp&quot;,<br>                &quot;-o&quot;,<br>                &quot;${workspaceFolder}/demo.exe&quot;<br>            ],<br>            &quot;options&quot;: {<br>                &quot;cwd&quot;: &quot;${workspaceFolder}&quot;<br>            },<br>            &quot;group&quot;: {<br>                &quot;kind&quot;: &quot;build&quot;,<br>                &quot;isDefault&quot;: true<br>            },<br>            &quot;problemMatcher&quot;: []<br>        }<br>    ]<br>}</pre><p>The -static flag tells the compiler to embed all library dependencies directly into the .exe file.</p><p><strong>I rebuilt with </strong><strong>Ctrl+Shift+B and ran it:</strong></p><pre>D:\Chandana\Practise_work\cpp&gt;.\demo.exe<br>Hello, World!<br>D:\Chandana\Practise_work\cpp&gt;</pre><p><strong>Perfect!</strong> The program ran successfully and printed “Hello, World!”</p><h3>Step 9: Making It More Flexible</h3><p>I wanted my setup to work like a competitive programming environment where:</p><ul><li>Any .cpp file can be compiled (not just demo.cpp)</li><li>Input comes from input.txt</li><li>Output goes to output.txt</li><li>It works with paths containing spaces</li></ul><p><strong>I created my final tasks.json:</strong></p><pre>{<br>    &quot;version&quot;: &quot;2.0.0&quot;,<br>    &quot;tasks&quot;: [<br>        {<br>            &quot;label&quot;: &quot;compile&quot;,<br>            &quot;type&quot;: &quot;shell&quot;,<br>            &quot;command&quot;: &quot;C:/msys64/ucrt64/bin/g++.exe&quot;,<br>            &quot;args&quot;: [<br>                &quot;-std=c++17&quot;,<br>                &quot;-Wall&quot;,<br>                &quot;-static&quot;,<br>                &quot;-o&quot;,<br>                &quot;${fileBasenameNoExtension}&quot;,<br>                &quot;${file}&quot;<br>            ],<br>            &quot;options&quot;: {<br>                &quot;cwd&quot;: &quot;${fileDirname}&quot;<br>            },<br>            &quot;group&quot;: {<br>                &quot;kind&quot;: &quot;build&quot;,<br>                &quot;isDefault&quot;: false<br>            },<br>            &quot;problemMatcher&quot;: []<br>        },<br>        {<br>            &quot;label&quot;: &quot;compile and run&quot;,<br>            &quot;type&quot;: &quot;shell&quot;,<br>            &quot;command&quot;: &quot;C:/msys64/ucrt64/bin/g++.exe -std=c++17 -Wall -static -o \&quot;${fileBasenameNoExtension}\&quot; \&quot;${file}\&quot; &amp;&amp; .\\${fileBasenameNoExtension} &lt; input.txt &gt; output.txt&quot;,<br>            &quot;options&quot;: {<br>                &quot;cwd&quot;: &quot;${fileDirname}&quot;<br>            },<br>            &quot;group&quot;: {<br>                &quot;kind&quot;: &quot;build&quot;,<br>                &quot;isDefault&quot;: true<br>            },<br>            &quot;problemMatcher&quot;: []<br>        }<br>    ]<br>}</pre><p><strong>Key features:</strong></p><ul><li>${file} - Compiles whatever file I have open</li><li>${fileBasenameNoExtension} - Creates .exe with the same name as the .cpp file</li><li>${fileDirname} - Works in any folder</li><li>-static - No DLL dependency issues</li><li>&lt; input.txt &gt; output.txt - Redirects input/output for testing</li></ul><h3>Summary: What I Learned</h3><p><strong>The Bug:</strong> GCC 15.2.0 has a known issue where cc1plus.exe and generated executables can&#39;t find the clock_gettime64 procedure entry point in required DLLs.</p><p><strong>The Solution:</strong></p><ol><li><strong>For compilation:</strong> Copy all DLLs from C:\msys64\ucrt64\bin\ to C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.2.0\</li><li><strong>For runtime:</strong> Use the -static flag when compiling to embed all dependencies</li></ol><p><strong>Commands Used:</strong></p><pre># Fix compilation<br>cd C:\msys64\ucrt64\bin<br>copy *.dll C:\msys64\ucrt64\lib\gcc\x86_64-w64-mingw32\15.2.0\</pre><pre># Build with static linking<br>g++ -std=c++17 -Wall -static demo.cpp -o demo.exe</pre><p>This debugging journey taught me about DLL dependencies, the difference between compile-time and runtime linking, and how to properly configure VS Code for C++ development with MSYS2</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b98ad83f42a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mysys2 explained]]></title>
            <link>https://medium.com/@chandanarajiv01/mysys2-explained-ef4a2b20883e?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef4a2b20883e</guid>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 04:59:06 GMT</pubDate>
            <atom:updated>2025-11-28T04:59:06.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*vpgqiW3Vo7DMIHWsb3kkxA.png" /></figure><h3>MSYS2 has 5 environments (or “shells”)</h3><p>Each one is meant for a different purpose and uses different compilers.</p><h3>1. MSYS (msys shell)</h3><pre>C:\msys64\msys2.exe</pre><p>❌ Not for normal C++ development</p><p>✔ Uses minimal POSIX tools (bash, sed, awk)<br> ✔ Compiler: <strong>NONE (not meant for building Windows programs)</strong><br> ✔ Used internally by MSYS2 for its own package builds.</p><h3>2. MINGW64 (mingw-w64)</h3><pre>C:\msys64\mingw64.exe</pre><h3>✔ Most common for C++ on Windows</h3><p>Compiler path:</p><pre>C:\msys64\mingw64\bin\g++.exe</pre><h3>Output:</h3><p>✔ Produces <strong>native Windows .exe</strong> (using MinGW-w64 runtime)</p><h3>3. UCRT64 (Universal C Runtime)</h3><pre>C:\msys64\ucrt64.exe</pre><h3>✔ Modern recommended environment</h3><p>Compiler path:</p><pre>C:\msys64\ucrt64\bin\g++.exe</pre><h3>Output:</h3><p>✔ Produces Windows .exe<br> ✔ Uses Microsoft’s <strong>UCRT</strong> runtime (more compatible &amp; stable)</p><h3>4. CLANG64</h3><pre>C:\msys64\clang64.exe</pre><h3>✔ Uses the Clang/LLVM compiler</h3><p>Compiler path:</p><pre>C:\msys64\clang64\bin\clang++.exe</pre><h3>Output:</h3><p>✔ Windows native .exe<br> ✔ Faster build times, better warnings</p><h3>5. CLANG32 / MINGW32 (sometimes optional depending on install)</h3><p>These are 32-bit versions:</p><ul><li>mingw32</li><li>clang32</li></ul><p>Most modern developers don’t use 32-bit anymore.</p><h3>If you install GCC in ucrt64, it does <strong>not</strong> install it in mingw64.</h3><p>That’s why you see:</p><pre>C:\msys64\ucrt64\bin\g++.exe</pre><p>But not in mingw64 unless installed separately.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef4a2b20883e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to do masking in Metashape]]></title>
            <link>https://medium.com/@chandanarajiv01/how-to-do-masking-in-metashape-d42327282fc3?source=rss-9d89ab8b31a9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d42327282fc3</guid>
            <category><![CDATA[agisoft-metashape-pro]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[photoshop]]></category>
            <category><![CDATA[masking]]></category>
            <category><![CDATA[agisoft-metashape]]></category>
            <dc:creator><![CDATA[Chandana Rajeev]]></dc:creator>
            <pubDate>Fri, 17 Oct 2025 07:29:31 GMT</pubDate>
            <atom:updated>2025-10-17T07:29:31.284Z</atom:updated>
            <content:encoded><![CDATA[<p>I referred this video <a href="https://www.youtube.com/watch?v=A-N8zD6svvY&amp;t=25s">https://www.youtube.com/watch?v=A-N8zD6svvY&amp;t=25s</a></p><p>Metashape version 1.8.4</p><h4>Step 1 : Take a sample image</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J1t7m-csiUAc7ArOjKKM7Q.png" /></figure><h4>Step 2 : Go to selection tool</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*_pt5SpJFlJVNwwTaGPN8vQ.png" /></figure><h4>Step 3 : Using tools to select area to be masked out</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*0Qafqe2IB2UAP5uld0rBuA.png" /></figure><h4><strong>Option A: Intelligent Scissors</strong></h4><p>1. Select the <strong>Intelligent scissors</strong> tool.</p><p>2. Click once to start the line, then continue clicking sequentially along the desired outline to define the boundary. Precision is helpful, but the line does not have to be absolutely perfect.</p><p>3. Right-click and choose <strong>Add selection</strong> to incorporate the refined boundary into the mask.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TzwXA6oXEDvUOYvBspwavg.png" /></figure><h4>Option B : Intelligent paint tool</h4><p>Intelligent paint tool is used to “paint” a selection by the mouse, continuously adding small image regions, bounded by object boundaries.</p><h4>Option C : Magic Wand Tool</h4><p>Magic Wand tool is used to select uniform areas of the image. To make a selection with a Magic Wand tool, click inside the region to be selected. The range of pixel colors selected by Magic Wand is controlled by the tolerance value. At lower tolerance values the tool selects fewer colors similar to the pixel you click with the Magic Wand tool. Higher value broadens the range of colors selected.</p><p>The tool might not be limited strictly by adjacent color; it might also detect nearby colors and select them, causing the selection to <strong>“bleed through”</strong> into the object</p><p>To select more than one space simultaneously, you should <strong>hold down the Control key</strong> while clicking, similar to the method used in Photoshop</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CF1UVdDHmOXSdhu7nfPuHg.png" /></figure><h4>Step 4 : Refining</h4><p>After selecting the necessary background areas, you <strong>right-click</strong> within the selection and choose <strong>Add selection</strong> to create the mask outline. If too much area was selected, you can also use <strong>Subtract selection</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iK9NVk3_Mj3yssnpSIerpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HLVYIPRUnTCgLJqV2V850Q.png" /></figure><p>The unwanted area is selected using rectangular selection tool, you will find it in selection tools menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*0Qafqe2IB2UAP5uld0rBuA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*aUrlPqKbm3DDyQbLhLJndQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S5UmHVwNmR0y7AgRZfZrRg.png" /></figure><p>then click on add selection to remove that area, Just like that you can play around and create the mask.</p><h4>Exporting masks</h4><p>Created masks can be also saved for external editing or storage.</p><p>To export masks</p><ol><li>Select Export Masks… command from the File menu.</li><li>In the Export Mask dialog select suitable parameters. Click OK button when done.</li><li>Browse to the folder where the masks should be saved and select it. Editing 120</li><li>The progress dialog box will appear displaying the current processing status. To cancel processing click Cancel button.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*5tYQjuGBMLXvUG2uG1TwGw.png" /></figure><p>Export masks for Specifies whether masks should be exported for the currently opened photo, active chunk or entire Workspace.</p><p>Current photo — save mask for the currently opened photo (if any).</p><p>Active chunk — save masks for active chunk.</p><p>Entire workspace — save masks for all chunks in the project.</p><p>File type Specifies the type of generated files.</p><p>Single channel mask image — generates single channel black and white mask images.</p><p>Image with alpha channel — generates color images from source photos combined with mask data in alpha channel.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d42327282fc3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>