<?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 Prathyash Joy Binu on Medium]]></title>
        <description><![CDATA[Stories by Prathyash Joy Binu on Medium]]></description>
        <link>https://medium.com/@prathyashjb?source=rss-ad2fc3e7de3d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c4-RQ8cdxHinDHXel0PsQw.jpeg</url>
            <title>Stories by Prathyash Joy Binu on Medium</title>
            <link>https://medium.com/@prathyashjb?source=rss-ad2fc3e7de3d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:11:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prathyashjb/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[Agentic AI: New Frontier in Gen AI]]></title>
            <link>https://medium.com/@prathyashjb/agentic-ai-new-frontier-in-gen-ai-9b77962a9ec4?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b77962a9ec4</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 15:08:09 GMT</pubDate>
            <atom:updated>2025-12-04T15:08:09.577Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PWwuJxJnkyclTxvG" /><figcaption>Photo by <a href="https://unsplash.com/@omilaev?utm_source=medium&amp;utm_medium=referral">Igor Omilaev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Introduction</h4><p>As AI continues to evolve, we are entering a new paradigm — one where systems don’t just assist users, but<strong> act</strong> on their behalf. <strong>Agentic AI</strong>, defined by its ability to make decisions, take initiative, and pursue goals independently, is transforming how we interact with technology. While traditional AI tools focus on generating content or responding to input, agentic systems go further: they plan, reason, and execute complex, multi-step tasks with minimal human oversight.</p><p>This shift marks the next frontier of AI systems that leverage advanced reasoning and iterative planning to autonomously solve problems in dynamic environments. With real-time adaptability across diverse contexts, Agentic AI promises to boost productivity and revolutionize operations across industries.</p><p>For example, in customer care, an agentic AI can autonomously resolve complex issues like billing disputes by reviewing account data, applying policies, and delivering personalized responses. It can also escalate cases or schedule callbacks when necessary, enhancing customer satisfaction while reducing the workload on human agents.</p><h4>How is Agentic AI unique from other AI stacks?</h4><p>Agentic systems offer significant advantages over their generative predecessors, which are constrained by the information available in their training datasets</p><p><strong>Adaptable</strong></p><p>Agents can reason and evaluate their own responses, allowing them to learn continuously and course-correct as needed. This adaptability enables the system to adjust its behavior based on real-time information and newly emerging changes. For instance, a customer service AI agent might initially provide a standard solution to a problem, but if the customer indicates it didn’t work, the agent can reevaluate its approach, learn from the feedback, and try a different solution next time, improving its responses over time</p><p><strong>Autonomous</strong></p><p>Leveraging the powerful reasoning of large language models combined with the specialized skills of agents, agentic AI can operate independently, autonomously performing specific tasks without constant human supervision. This capability allows continuous operation in environments where human oversight is limited or not required. Such autonomous systems can maintain long-term goals, manage complex multi-step tasks, and track progress over time.</p><p><strong>Specialized</strong></p><p>AI agents can be customized with specific expertise to excel in particular domains or tasks. Unlike general-purpose AI, specialized agents focus on well-defined areas such as finance, healthcare, or customer service, enabling them to deliver more accurate, efficient, and context-relevant outcomes. Within the finance sector, for example, agents can be further specialized for tasks like accounting, customer onboarding, or customer care, allowing even more precise and effective performance.</p><p><strong>Instinctive</strong></p><p>Imagine the employee onboarding process in a large organization. Traditionally, new hires have to fill out forms, access multiple platforms for training, benefits, and payroll setup, and wait on HR for answers to basic questions.</p><p>With an agentic AI system, this experience becomes seamless. A new employee can simply ask, “What training modules do I need to complete this week?” or “How do I enroll in health benefits?” The AI agent can fetch relevant documents, schedule training, pre-fill forms, and even provide real-time answers — all through a conversational interface.</p><p>Instead of navigating multiple systems and instructions, employees are guided through the process by an intelligent agent that understands context and handles multi-step tasks behind the scenes.</p><h4><strong>How does an AI agent work?</strong></h4><p>AI agents use the following process for problem-solving</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*59rA7r_AcqEBvbg_4pHI7w.png" /></figure><ol><li><strong>Preception</strong></li></ol><p>Perception is the initial phase where AI agents gather and process data from a variety of sources. This can include structured and unstructured data from databases, logs, PDFs, APIs, or real-time inputs from sensors. The goal is to extract meaningful features and insights that will inform the agent’s decision-making process.</p><p><em>For example, in an autonomous vehicle, sensors like LIDAR, Camera, etc collect data from its surroundings and process it for further stages</em></p><p><strong>2. Cognition</strong></p><p>The cognition layer is where the agent interprets the data and makes informed decisions. AI agents often incorporate Large Language Models (LLMs) as their core reasoning engine. In this role, the LLM serves as an orchestrator, understanding tasks, interpreting context, and coordinating different sub-agents or modules based on the inputs received from the perception stage.</p><p>During this stage, AI agents apply logical rules, heuristics, or previously learned knowledge to analyze the data and determine the best course of action. This is what gives the agent its “intelligent” behavior, allowing it to adapt to new inputs and dynamically adjust its strategies.</p><p><strong>3. Action</strong></p><p>Based on its reasoning, the AI agent proceeds to take appropriate actions aimed at achieving its defined objectives. These actions can be <strong>physical</strong>, such as a robot manipulating objects, or <strong>digital</strong>, like generating a report, sending an email, or triggering an automated workflow.</p><p>To execute these actions, AI agents are often integrated with external tools, APIs, or software systems. This enables them to interact with both the physical and digital environments effectively.</p><p><strong>4. Learning</strong></p><p>Agentic AI improves over time through feedback and reinforcement learning. This ability to adapt makes it a powerful tool for enhancing decision-making and efficiency.</p><p><em>For example, a customer service AI agent might detect a new issue reported by callers. It can then adjust its responses for future calls, handling the problem more effectively without human input.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*QFfAcBCoCSHHr7hpcG_tNQ.png" /></figure><h4>How Agentic AI Fuels Business Applications</h4><ol><li><strong>Retail Analytics</strong></li></ol><p>In retail, agentic AI acts as an intelligent assistant that can analyze vast amounts of data, such as customer behavior, sales trends, and inventory levels, and make real-time decisions or recommendations. Unlike traditional analytics systems, agentic AI doesn’t just present insights; it can autonomously act on them, like adjusting prices, analysis of sales, optimizing inventory, or personalizing promotions.</p><p>For instance, an AI agent might detect a sudden spike in demand for a product in a specific region and automatically reorder stock or launch a targeted marketing campaign, helping retailers respond faster and more effectively to market changes.</p><p><strong>2. Customer Care</strong></p><p>Agentic AI is transforming call center operations by acting as an intelligent, self-improving assistant. Unlike traditional systems that follow fixed scripts, agentic AI can understand context, learn from past interactions, and adapt in real time to provide better support.</p><p>It can handle routine inquiries, route complex issues to human agents, and personalize conversations using customer history and sentiment analysis. For instance, if the AI detects a new recurring issue during calls, it can adjust its response strategy, update its knowledge base, or inform supervisors — all without human prompting.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b77962a9ec4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fine Tuning LLMs]]></title>
            <link>https://medium.com/@prathyashjb/fine-tuning-llms-eaef7da1415e?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaef7da1415e</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Mon, 29 Jan 2024 07:29:24 GMT</pubDate>
            <atom:updated>2024-02-06T10:54:30.687Z</atom:updated>
            <content:encoded><![CDATA[<p><em>As we know the knowledge base of LLM is restricted to general and open-source data, think about a scenario where you want your internal dataset to be included in LLMs for reasoning and other purposes. In this article, we will be focusing on finetuning the LLM model for task-specific requirements based on the custom dataset.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SWHe4I8Ek5MoAbdZmSqw7A.png" /></figure><h3>Ways of Fine-Tuning</h3><ol><li><strong>Supervised fine-tuning (SFT)</strong></li></ol><p>Supervised fine-tuning means updating a pre-trained language model using labeled data to do a specific task. The data used has been checked earlier. This is different from unsupervised methods, where data isn’t checked. Usually, the initial training of the language model is unsupervised, but fine-tuning is supervised. These types of methods are commonly used in fine-tuning process.</p><p><strong>2. Reinforcement learning from human feedback (RLHF)</strong></p><p>Reinforcement learning from human feedback (RLHF) is a machine learning technique that uses human feedback to fine-tune and train large language models (LLMs). RLHF allows LLMs to understand user intent, even when it’s not explicitly stated.</p><h3>How is fine-tuning performed?</h3><p>Fine-tuning is a crucial step in enhancing large language models (LLMs) through transfer learning. It involves adjusting an LLM’s parameters with task-specific data and maintaining its original training knowledge. This allows models like BERT or GPT-4 to excel in specific tasks while preserving their language understanding. The fine-tuning process comprises two phases: preparation and fine-tuning. Also, various data training techniques encompass data synthesis, continual learning, transfer learning, one-shot learning, few-shot learning, and multi-task learning, warranting careful consideration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgR62kuKQkgcNeMrY30_Cg.jpeg" /></figure><p>Here we will be using the Supervised Fine Tuning Approach. The following steps are carried out while fine-tuning a model.</p><h3>Preparation Phase</h3><h4><strong>1. Choose fine-tuning task</strong></h4><p>Before moving to fine-tuning, firstly we need to select a task that should perform specific functionalities like medical assistant, personal assistant, document summarization, etc.</p><h4><strong>2. Prepare Dataset</strong></h4><p>While fine-tuning a base LLM, it is recommended to use only labeled or structured data so that the model can easily learn patterns. Detailed ways of preparing datasets for fine-tuning will be explained in another article.</p><h4><strong>3. Data Augmentation</strong></h4><p>Data quality and size play an important role in the fine-tuning process. Try to use data augmentation methods to increase the diversity of the training data</p><h3>Model Fine-Tuning Phase</h3><h4><strong>1. Select a Pre- Trained Model</strong></h4><p>Based on the task, select an open-source LLM. This pre-trained model, having been trained on a vast corpus of text, possesses a broad comprehension of language. Commonly used models are Phi2, LLama, MPT, Falcon, etc. Pre Trained Model selection should be strictly done based on the type of application.</p><p>You can access a variety of open-source models through the <strong>hugging face</strong> platform. Following is the list of some open-source LLMs which can be tried out.</p><ul><li><a href="https://huggingface.co/microsoft/phi-2">microsoft/phi-2 · Hugging Face</a></li><li><a href="https://huggingface.co/meta-llama/Llama-2-7b-chat-hf">meta-llama/Llama-2-7b-chat-hf · Hugging Face</a></li><li><a href="https://huggingface.co/tiiuae/falcon-7b-instruct">tiiuae/falcon-7b-instruct · Hugging Face</a></li></ul><h4><strong>2. Fine Tuning Methods</strong></h4><p>Fine-tuning an LLM can be done in 4 ways.</p><ol><li><strong>Retrain all the paramters</strong></li></ol><p>Here all weight parameters of the pre-trained model are retrained and changed when fine tuning is done. This approach requires a high computational environment and data quality.</p><p><strong>2. Transfer Learning</strong></p><p>In transfer learning, most of the layers are kept frozen and only the last layers/heads are fine-tuned based on the task.</p><p><strong>3. Parameter Efficient Fine Tuning</strong></p><p>PEFT approaches only fine-tune a small number of (extra) model parameters while freezing most parameters of the pre-trained LLMs, thereby greatly decreasing the computational and storage costs. This also overcomes the issues of <a href="https://arxiv.org/abs/1312.6211">f</a>orgetting, a behavior observed during the full finetuning of LLMs. Some of the commonly used PEFT methods are Lora, QLora, Adaptors etc. For detailed information, refer to the article below</p><p><a href="https://www.leewayhertz.com/parameter-efficient-fine-tuning/">Parameter-efficient Fine-tuning (PEFT): Overview, benefits, techniques and model training</a></p><h3>Reference</h3><p><a href="https://www.superannotate.com/blog/llm-fine-tuning">https://medium.com/r/?url=https%3A%2F%2Fwww.superannotate.com%2Fblog%2Fllm-fine-tuning</a></p><p><a href="https://www.leewayhertz.com/parameter-efficient-fine-tuning/">https://www.leewayhertz.com/parameter-efficient-fine-tuning/</a></p><p><a href="https://www.datacamp.com/blog/top-open-source-llms">https://www.datacamp.com/blog/top-open-source-llms</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaef7da1415e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Leverage AI For Brand Protection]]></title>
            <link>https://medium.com/@prathyashjb/leverage-ai-for-brand-protection-5a71d73aeb07?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a71d73aeb07</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Mon, 04 Sep 2023 15:11:37 GMT</pubDate>
            <atom:updated>2024-02-13T04:52:48.678Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, Let&#39;s see how we can use Artificial Intelligence to fight against brand exploitation</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*xLiIIpi-b5eD8c5qnozKSg.jpeg" /></figure><p>Recently, E-commerce gained much popularity and increased the profit of every product introduced by various brands. So here those E-commerce sites are game changers for these companies. For the past years, companies selling products through digital platforms have faced brand exploitation as a serious threat. The term brand exploitation refers to the unauthorized use of a brand’s identity, reputation, or intellectual property for selling purposes. It involves taking advantage of a well-established brand’s name, logo, or trademarks to deceive customers, promote sales of counterfeit products, or engage in fraudulent activities.</p><h3>Types of Brand Exploitation</h3><p>Before going to the remedies we must understand the ways and types of exploitation techniques currently fraudsters use to sell their counterfeits.</p><h4>1. Counterfeiting</h4><p>This refers to the production and sales of imitation products that infringe on a brand’s intellectual property rights. Counterfeit products are often similar to real products and can be difficult for customers to distinguish.</p><h4>2. Trademark Infringement</h4><p>This occurs when a third party uses a brand’s name, logo, or other intellectual property without permission, which can lead to confusion or dilution of the brand. Trademark infringement can occur in various forms, such as using a similar name, logo, or packaging that is likely to confuse customers.</p><h4>3. Domain squatting</h4><p>This occurs when a third party registers a domain name that is similar or identical to a brand’s name or trademark, with the intention of profiting from it. Domain squatters may use the domain to redirect traffic to their own website or to sell it back to the brand at an inflated price.</p><h4>4. Brand impersonation</h4><p>This occurs when a third party uses a brand’s name or logo to create a fake identity, often for fraudulent purposes. For instance, scammers may create fake social media profiles or email addresses to trick customers into revealing personal information or making payments.</p><h3>Role of AI in Prevention</h3><p>However, as technology has advanced, Artificial Intelligence has emerged as a strong tool for protecting businesses against brand exploitation. The application of AI in brand protection and anti-counterfeiting is diverse. It entails identifying counterfeit items and unauthorized distribution of commodities utilizing different AI-powered technologies such as computer vision, natural language processing, machine learning, graph analytics, and deep learning. Many companies are using computer vision techniques to fight against this exploitation. One of the most significant advantages of AI-powered brand protection is its potential to effectively detect counterfeit items and their supply chain.</p><h3>How can we build an AI solution !!!</h3><p>Building a solution for brand protection comprises various tech stacks like text mining, web scraping, computer vision, deep learning, and NLP. Before developing a solution there is a need for a massive amount of data in training the AI models. Those data may include images of products, descriptions, tags, product info, comments, domains, etc. Finally, the important thing to remember while developing the model is the generalization capability of the model at any input data. The common structure of the solution that most of the company uses is below shown</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*M4KFyaJMgPjihB0c9orGjA.png" /></figure><p>Any architecture or method can be used based on complexity and effectiveness but it should be comprised of steps like Data Scrapping, Data Analysis, and Report Generation. Based on the research done, I prepared this architecture that most companies rely on to find counterfeits.</p><h4><strong>Step 1. Scraping Data</strong></h4><p>Acquisition of data is one of the crucial phases in brand protection. Without real-time data from various sources like websites, e-commerce platforms, and image results, it is not possible to detect counterfeits and brand exploitation. Apart from that everyone will be bothered about, How to extract these data from the internet.</p><p>The data extraction process should extract data from user-predefined<strong><em> websites </em></strong>that are high risk as well as extract data from any sources with only the <strong><em>keyword</em></strong> of the brand or product as input in a search. For the extraction process frameworks below can be used</p><ol><li>Selenium: A web automation tool to automate events like clicking, scrolling, hovering, downloading, etc.</li><li>Web scrapper: Build functions to extract data like text, product info, images, etc from the HTML tags of the websites.</li><li>Web crawling: Use paid API services to extract data from websites and e-commerce sites, here no code services are available</li></ol><p><strong>What Type of data needs to be extracted?</strong></p><ol><li>URL: Domain of the sites</li><li>Images: Images from websites as well as Google search results</li><li>Product info: Extract product info from the monitoring websites</li><li>Comments: Comments of the customers in different platform</li></ol><h4>Step 2. Data Analysis</h4><p>Here comes the most interesting and complex architecture for analyzing the data extracted from the scrapping module. In this phase, the data is analyzed using AI models that serve processes like logo comparison, product image comparison, text recognition, and domain analysis.</p><p><strong>What does each model do?</strong></p><ol><li><strong>Logo Comparison Model</strong>: This model should be capable of detecting the logos from the scrapped images. After detection, the model should compare the similarity of the detected logos to the original logo.</li></ol><p>Frameworks: Yolo (Logo Detection), Tensorflow, OpenCV (similarity detection)</p><p><strong>2. Product Comparison Model</strong>: Here this model should detect the product from the scrapped Image data and also predict the similarity of the scrapped image with a similar original product image.</p><p>Frameworks: Yolo (Logo Detection), Tensorflow, OpenCV (similarity detection)</p><p><strong>3. Text Recognition Model</strong>: This model should identify and classify fraudsters using the textual content in the product info including price, description, tags, product name, and comments.</p><p>Frameworks: Tensorflow, NLP, CNN</p><p><strong>4. Domain Model</strong>: Here the objective is to detect the high-risk domain based on the URL and website contents</p><p>All the above models should return a probability score based on the similarity with the original product data</p><h4>Step 3. Report Generation</h4><p>The last phase of the brand protection system is a report generation system in which all the anomalies and suspicious products are shown along with corresponding metadata like URL, images, price, etc. Here in this part all the probability scores from the AI model are validated with a threshold value. If any of the scores are found to be low, that product will flagged as a suspicious product.</p><p>The above-mentioned steps are a generalized architecture that can be changed according to the developer&#39;s needs and business use cases. But it is preferable to have core modules like scrapping, analysis</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a71d73aeb07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Face Detection using Haarcascade, OpenCV]]></title>
            <link>https://medium.com/@prathyashjb/face-detection-using-haarcascade-opencv-8031ca8578fd?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8031ca8578fd</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Wed, 23 Aug 2023 18:54:22 GMT</pubDate>
            <atom:updated>2023-08-23T18:54:22.993Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, we are familiarizing face and eye detection using Open CV’s Haarcascade classifier</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*8ZOPirlMnA74-H2TjW2gAA.png" /></figure><p>First of all, make sure that you have installed OpenCV.</p><pre>pip install opencv-python</pre><p>A “haar cascade classifier” is a machine learning-based approach for object detection. To train a haar cascade classifier for eye detection, the algorithm initially needs a lot of positive images (images of eyes) and negative images (images without eyes). Then the classifier is trained from these positive and negative images. It is then used to detect eyes in other images. We can use already trained haar cascades for eye detection. OpenCV already contains many pre-trained classifiers for face, eyes, smiles, etc.</p><h3>Detect From Images</h3><p>Here the input is given in the image format. From the image, w will be detecting the faces</p><h4><strong>Step 1: For downloading pre-trained classifiers</strong></h4><p>Create a folder named <strong>haarcascades. </strong>Please download the file inside the <strong>haarcascades </strong>folder</p><p>Download the classifier from the GitHub repo of OpenCV. You need to download the <a href="https://raw.githubusercontent.com/opencv/opencv/master/data/haarcascades/haarcascade_frontalface_default.xml">trained classifier XML file</a></p><h4>Step 2: Create a detector</h4><pre><br>import cv2<br><br># Load the cascade<br>face_cascade = cv2.CascadeClassifier(&#39;D:/Projects/openCV/haarcascades/haarcascade_frontalface_default.xml&#39;)<br># Read the input image<br>img = cv2.imread(&#39;images/test.jpg&#39;)<br># Convert into grayscale<br>gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br># Detect faces<br>faces = face_cascade.detectMultiScale(gray, 1.1, 4)<br># Draw rectangle around the faces<br>for (x, y, w, h) in faces:<br>    cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)<br># Display the output<br>cv2.imshow(&#39;img&#39;, img)<br>cv2.waitKey()</pre><p>Note: The detection works only on grayscale images. So it is important to convert the color image to grayscale</p><p><strong>detectMultiScale </strong>function (line 10) is used to detect the faces. It takes 3 arguments — the input image, <em>scaleFactor,</em> and <em>minNeighbours</em>. <em>scaleFactor</em> specifies how much the image size is reduced with each scale. <em>minNeighbours </em>specifies how many neighbors each candidate rectangle should have to retain it.</p><p>The output of the classifier will be a set coordinate with the region where the face is found</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*q9Av_B-unvqO_Lf2wxdagg.png" /></figure><h3>Detect From Videos</h3><p>The only difference here is we running the face detector in an infinite loop where each frame is given to the face detector.</p><pre>import cv2<br><br># Load the cascade<br>face_cascade = cv2.CascadeClassifier(&#39;haarcascade_frontalface_default.xml&#39;)<br><br># To capture video from webcam. <br>cap = cv2.VideoCapture(0)<br># To use a video file as input <br># cap = cv2.VideoCapture(&#39;filename.mp4&#39;)<br><br>while True:<br>    # Read the frame<br>    _, img = cap.read()<br>    # Convert to grayscale<br>    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br>    # Detect the faces<br>    faces = face_cascade.detectMultiScale(gray, 1.1, 4)<br>    # Draw the rectangle around each face<br>    for (x, y, w, h) in faces:<br>        cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)<br>    # Display<br>    cv2.imshow(&#39;img&#39;, img)<br>    # Stop if escape key is pressed<br>    k = cv2.waitKey(30) &amp; 0xff<br>    if k==27:<br>        break<br># Release the VideoCapture object<br>cap.release()</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8031ca8578fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of OpenCV, Part 2]]></title>
            <link>https://medium.com/@prathyashjb/basics-of-opencv-part-2-dfa4dcf5469b?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfa4dcf5469b</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Wed, 23 Aug 2023 05:56:51 GMT</pubDate>
            <atom:updated>2023-08-23T05:56:51.822Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, we will be familiarizing the basic functions of OpenCV while handling images.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*-pRnok3A15BNqcesY_YwWA.png" /></figure><p>Here we will get an idea of the useful operations that can be done on images for better results. Those include blurring, denoising, thresholding, dilation, etc. If you are not familiar with basic OpenCV image operations like rotation, drawing, etc, please refer the part 1.</p><p><a href="https://medium.com/@prathyashjb/basics-of-opencv-part-1-fe9f7b4ed650">Basics of OpenCV, Part 1</a></p><h3># Creating a Reusable function</h3><p>With the help of the below function, we can visualize the output of the open cv function that here we use.</p><pre>import cv2<br>import matplotlib.pyplot as plt<br>def imshow(title = &quot;Image&quot;, image = None ,size =10):<br>    w, h = image.shape[0], image.shape[1]<br>    asp_rations =w/h<br>    <br>    plt.figure(figsize=(size*asp_rations,size))<br>    plt.imshow(image)<br>    plt.title(title)<br>    plt.show()</pre><h4><strong>1. Image Blurring</strong></h4><p>Image Blurring refers to making the image less clear or distinct. There are some advantages to doing blurring techniques.</p><ol><li>Noise removal</li><li>Smoothing the image.</li><li>Low-intensity edges are removed.</li></ol><pre>image = cv2.imread(&quot;Image.jpg&quot;)<br><br># Basic Image Blurring<br><br>blur = cv2.blur(image,(500,500))<br>imshow(&quot;Blurred image&quot;,image)<br><br># Gaussian Image Blurring<br>Gaussian = cv2.GaussianBlur(image, (7, 7), 0)<br>imshow(&#39;Gaussian Blurring&#39;, Gaussian)<br><br># Median Blur<br>median = cv2.medianBlur(image, 5)<br>imshow(&#39;Median Blurring&#39;, Gaussian)<br></pre><h4>2. Image Denoising</h4><p>Denoising an image refers to the process of reconstruction of a signal from noisy images. Denoising is done to remove unwanted noise from the image to analyze it in a better form. It refers to one of the major pre-processing steps.</p><pre>image = cv2.imread(&quot;Image.jpg&quot;)<br><br>dst = cv2.fastNlMeansDenoisingColored(image, None, 10, 10, 7, 15)<br>imshow(&#39;Denoising&#39;, dst)</pre><h4>3. Edge Detection</h4><p>Edge detection is one of the fundamental image-processing tasks used in various Computer Vision tasks to identify the boundary or sharp changes in the pixel intensity. It plays a crucial role in object detection, image segmentation, and feature extraction from the image. In Real-time edge detection, the image frame coming from a live webcam or video is continuously captured and each frame is processed by edge detection algorithms which identify and highlight these edges continuously.</p><pre>image = cv2.imread(&quot;Image.jpg&quot;)<br>img = cv2.Canny(image,60,110)<br>imshow(&#39;Edge&#39;, img)</pre><h4>4. Contours</h4><p>Contours are continuous lines that cover the full boundary of an object.</p><p>Note: Try to threshold the image before doing the contours.</p><pre>image = cv2.imread(&quot;Image.jpg&quot;)<br><br>#convert to grey scale<br><br>gray = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)<br><br>#Thresholding the image<br><br>_, th2 = cv2.threshold(gray, 0,255,cv2.THRESH_BINARY + cv2.THRESH_OTSU)<br><br># Finding Contours<br>contours, hierarchy = cv2.findContours(th2, cv2.RETR_LIST,cv2.CHAIN_APPROX_NONE)<br>cv2.drawContours(image,contours,(0,255,0),2)<br><br>imshow(&#39;Contours&#39;, image)</pre><h4>5. Line Detection</h4><pre>img = cv2.imread(&#39;image.jpg&#39;)<br>gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br>edges = cv2.Canny(gray, 50, 150, apertureSize=3)<br><br># This returns an array of r and theta values<br>lines = cv2.HoughLines(edges, 1, np.pi/180, 200)<br>for r_theta in lines:<br>    arr = np.array(r_theta[0], dtype=np.float64)<br>    r, theta = arr<br>    # Stores the value of cos(theta) in a<br>    a = np.cos(theta)<br> <br>    # Stores the value of sin(theta) in b<br>    b = np.sin(theta)<br> <br>    # x0 stores the value rcos(theta)<br>    x0 = a*r<br> <br>    # y0 stores the value rsin(theta)<br>    y0 = b*r<br> <br>    # x1 stores the rounded off value of (rcos(theta)-1000sin(theta))<br>    x1 = int(x0 + 1000*(-b))<br> <br>    # y1 stores the rounded off value of (rsin(theta)+1000cos(theta))<br>    y1 = int(y0 + 1000*(a))<br> <br>    # x2 stores the rounded off value of (rcos(theta)+1000sin(theta))<br>    x2 = int(x0 - 1000*(-b))<br> <br>    # y2 stores the rounded off value of (rsin(theta)-1000cos(theta))<br>    y2 = int(y0 - 1000*(a))<br> <br>    # cv2.line draws a line in img from the point(x1,y1) to (x2,y2).<br>    # (0,0,255) denotes the colour of the line to be<br>    # drawn. In this case, it is red.<br>    cv2.line(img, (x1, y1), (x2, y2), (0, 0, 255), 2)<br><br>imshow(&#39;Line Detection&#39;, img)</pre><h4>6. Template Matching</h4><p>For template matching, we need at least 2 images.</p><p>Limitations</p><ol><li>Pattern occurrences have to preserve the orientation of the reference pattern image(template)</li><li>As a result, it does not work for rotated or scaled versions of the template as a change in shape/size/shear, etc. of object w.r.t. the template will give a false match.</li><li>The method is inefficient when calculating the pattern correlation image for medium to large images as the process is time-consuming.</li></ol><pre>#input Image<br><br>img = cv2.imread(&#39;input.jpg&#39;)<br><br>#Convert to gray scale<br>gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)<br><br>#Load template image<br>template = cv2.imread(&#39;template.jpg&#39;)<br><br>result = cv2.matchTemplate(gray,template,cv2.TM_CCOEFF)<br>min_val, max_val, min_loc,max_loc = cv2.minMaxLoc(result)<br><br>#create bounding box of detected region<br><br>top_left = max_loc<br>bottom_right = (top_left[0]+50,top_left[1]+50)<br>cv2.rectangle(image,top_left,bottom_right,(0,255,0),5)<br><br>imshow(&#39;Template Matching&#39;, img)<br><br><br><br></pre><h4>6. Corner Detection</h4><p><strong>Harris Corner detection</strong> algorithm was developed to identify the internal corners of an image. The corners of an image are basically identified as the regions in which there are variations in the large intensity of the gradient in all possible dimensions and directions.</p><pre>img = cv2.imread(&#39;image.jpg&#39;)<br>gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br><br>gray = np.float32(gray)<br>corners = cv2.cornerHarris(gray, 2, 3, 0.05)<br><br>corners = cv2.dilate(corners, None)<br>img[corners &gt; 0.01 * corners.max()]=[0, 0, 255]<br><br>imshow(&#39;Corner Detection&#39;, img)<br></pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfa4dcf5469b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of OpenCV, Part 1]]></title>
            <link>https://medium.com/@prathyashjb/basics-of-opencv-part-1-fe9f7b4ed650?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe9f7b4ed650</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Wed, 09 Aug 2023 17:15:54 GMT</pubDate>
            <atom:updated>2023-08-09T17:21:43.125Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In this article, we will be familiarizing the basic functions of OpenCV while handling images and video.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LY3BBC1RJcZGYetLX6SIiQ.png" /></figure><p>OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human. When it is integrated with various libraries, such as NumPy, python is capable of processing the OpenCV array structure for analysis. To Identify an image pattern and its various features we use vector space and perform mathematical operations on these features.</p><h3>Application</h3><p>These are some common applications of OpenCV currently used in various sectors</p><ol><li>Object detection &amp; Counting</li><li>Edge Detection</li><li>Number plate recognition</li><li>Optical character recognition</li><li>Inspection and surveillances</li><li>Pattern matching</li></ol><h3>Basics</h3><p>Let&#39;s work on the basic function like visualization, saving, rescaling,buring resizing, etc. while dealing with images and videos.</p><h4>1. Image Visualization and Saving</h4><p>For visualizing the image use the below code to display. Change the file path according to your need.</p><pre>import cv2 as cv<br><br>img = cv.imread(&quot;cat.png&quot;)<br>cv.imshow(&#39;Cat&#39;, img)<br><br>#save image as a file<br><br>cv.imwrite(&#39;image.jpg&#39;,img)<br></pre><p>The above code will open a window showing the image you want to display and also save. In the Save function, we need to specify two arguments</p><ol><li><em>Name of the file you need to save</em></li><li><em>Source of the image</em></li></ol><h4>2. Video Visualization and Saving</h4><p>For reading the video, we need to use the code below to read the frames one by one.</p><pre>import cv2 <br><br># video writer configuration<br>fourcc = cv2.VideoWriter_fourcc(*&quot;XVID&quot;)<br>out = cv2.VideoWriter(&#39;output.avi&#39;, fourcc,20.0,(600,600))<br><br><br>cap =cv2.VideoCapture(0)#can also add the video files by specifying the path<br><br>while (True):<br>    <br>    ret, frame = cap.read()<br>    if ret == True:<br>        cv2.imshow(&quot;video capture&quot;, frame)<br>        <br>        #save video capture<br>        out.write(frame)<br>        <br>        if cv2.waitKey(1) &amp; 0xFF == ord(&#39;q&#39;):<br>            break<br>        <br>    else:<br>        break<br><br>    <br>cap.release()<br>cv2.destroyAllWindows()</pre><p>The above code will read the visuals from the camera and save them to the specified location.</p><p>Till now we got the idea of visualizing and saving images and videos. Before moving to further steps. Now let us create a reusable function for visualizing the various action like blurring, resizing, drawing, etc. Here the image is displayed using matplotlib.</p><h4># Creating a Reusable function</h4><p>With the help of the below function, we can visualize the output of the open cv function that here we use.</p><pre>import cv2<br>import matplotlib.pyplot as plt<br><br>def imshow(title = &quot;Image&quot;, image = None ,size =10):<br>    w, h = image.shape[0], image.shape[1]<br>    asp_rations =w/h<br>    <br>    plt.figure(figsize=(size*asp_rations,size))<br>    plt.imshow(image)<br>    plt.title(title)<br>    plt.show()</pre><h4>3. Gray Scaling an RGB Image</h4><p>Gray scaling is a method that is used to convert an RGB image to a Black and White image with channel 1. Before gray scaling the image, we need to open it using<strong> <em>cv2.imread. </em></strong>After that follow the code below mentioned</p><pre>image = cv2.imread(&quot;Image.jpg&quot;) <br>gray_image = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)<br>imshow(&quot;Test Image&quot;,gray_image)</pre><h4>4. Draw Over Images</h4><pre><br><br>#Draw a Rectangle<br>image = cv2.imread(&quot;Image.jpg&quot;)<br>cv2.rectangle(image,(0,0),(200,200),(100,254,255),4)<br>imshow(&quot;Color Test&quot;,image)<br><br># 3. Draw A Line<br>image = cv2.imread(&quot;Image.jpg&quot;)<br>cv2.line(image,(0,0),(200,200),(100,254,255),4)<br>imshow(&quot;Color Test&quot;,image)<br><br># 4. Draw a Polyline<br>image = cv2.imread(&quot;Image.jpg&quot;)<br>pts = np.array([[100,100],[300,300],[570,370]],np.int32)<br>cv2.polylines(image,[pts],True,(255,4,234),4)<br>imshow(&quot;Polygon Test&quot;,image)<br><br># 5. Write text<br>image = cv2.imread(&quot;Image.jpg&quot;)<br>cv.putText(image, &#39;Hello&#39;, (0,225), cv.FONT_HERSHEY_TRIPLEX, 1.0, (0,255,0), 2)<br>cv.imshow(&#39;Text&#39;, image)<br><br></pre><h4>5. Image Rotation</h4><p>In this code the image can be rotated in any direction.</p><pre>image = cv2.imread(&quot;Image.jpg&quot;)<br>w, h =image.shape[:2]<br>rotate =  cv2.getRotationMatrix2D((w/2,h/2),90,1)<br>rotated_image = cv2.warpAffine(image,rotate,(w,h))<br>imshow(&quot;Rotate Test&quot;,rotated_image)</pre><p>Another method of rotating the image is using transpose function.</p><pre>image = cv2.imread(&quot;Image.jpg&quot;)<br>cv2.transpose(image)<br>imshow(&quot;Rotate Test&quot;,image)</pre><h4>6. Image Resizing</h4><p>Using image resizing function we can change the dimension of the input image to desired dimension.</p><pre>image = cv2.imread(&quot;Image.jpg&quot;)<br># double the size of the image<br>cv2.resize(image, None, fx=2,fy=2, interpolation= cv2.INTER_CUBIC)<br><br># exact dimension <br>cv2.resize(image,(400,400),interpolation= cv2.INTER_CUBIC)</pre><h4>7. Cropping Image</h4><p>In some situation, we need to crop the image, using the snippet below we can crop the image.</p><pre>image = cv2.imread(&quot;Image.jpg&quot;)<br><br>crop = image[50:180, 100:300]  <br>imshow(&quot;Crop&quot;,crop)</pre><p>Above snippets are the basic function that we use to handle with images and videos. In the coming article, we will be having detailed explanation of other advanced function.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe9f7b4ed650" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Satellite Imagery Analysis, Part2]]></title>
            <link>https://medium.com/@prathyashjb/basics-of-satellite-imagery-analysis-part2-cc2d87d4b649?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc2d87d4b649</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Wed, 05 Jul 2023 07:11:27 GMT</pubDate>
            <atom:updated>2023-07-05T07:11:27.926Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In the article, we will be focusing on the hands-on experience in processing satellite imagery using Python for Computer vision tasks</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*3pstjIJfaC_kekcYvaniSg.jpeg" /></figure><p>Satellite Imagery can be assosicated with various applications like, crop monitoring, mineral exploration, urban planning, etc. Processing these types of images for computer vision tasks is not easy as you think when compared to normal RGB images. Before the action, I recommend you guys read the article regarding the theory and concepts of satellite imagery and its working.</p><p><a href="https://medium.com/@prathyashjb/basics-of-satellite-imagery-analysis-part1-d06ee23ab703">Basics of Satellite Imagery Analysis, Part1</a></p><p><em>Note: The image that we are going to deal with here consist of more than 3 channel. So Image processing and analysis are entirely different from the way that we commonly do it in computer vision applications.</em></p><p>Here let’s split the whole process into different modules.</p><ol><li><strong><em>Package Installation</em></strong></li></ol><p><strong><em>2. Download the Image</em></strong></p><p><strong><em>3. Image Processing</em></strong></p><p><strong><em>4. Image Analysis</em></strong></p><h3>Installations</h3><p>Please install the Python packages either in the local machine or use it in google colab, if you are going with online editors rather than local machines</p><pre>pip install rasterio<br>pip install sentinelsat<br>pip install geopandas<br>pip install matplotlib<br><br>#(Install GDAL with conda forge command )<br>pip install GDAL <br></pre><h3><strong>Where is our Image?</strong></h3><p>Our first step is to download the image. In the previous article, it is mentioned that we commonly use images from <strong>Landsat</strong> and <strong>Sentinal</strong> Satellites. For downloading the image there are some open source APIs are available, with some limitations at free quota.</p><p><strong>API Sources:</strong> <a href="https://scihub.copernicus.eu/twiki/do/view/SciHubWebPortal/APIHubDescription">https://scihub.copernicus.eu/twiki/do/view/SciHubWebPortal/APIHubDescription</a></p><p><a href="https://www.sentinel-hub.com/develop/api/">https://www.sentinel-hub.com/develop/api/</a></p><p>We will be using the <strong>Copernicus</strong> open-access hub to download the Sentinal Images. The Sentinel-2 acquires 13 spectral bands ranging from Visible and Near-Infrared to Shortwave Infrared wavelengths along a 290 km orbital swath. While its spatial resolution varies from 10m to 60m, the four bands wiz. red, blue, green, and NIR have a resolution of 10m per pixel.</p><p>Please import the Python packages below installed</p><pre><br>import folium<br>import geopandas as gpd<br>from sentinelsat.sentinel import SentinelAPI, read_geojson, geojson_to_wkt<br>import rasterio<br>import matplotlib.pyplot as plt<br>from rasterio import plot<br>from rasterio.plot import show<br>from rasterio.mask import mask<br>from osgeo import gdal<br>import numpy as np</pre><p>Before calling the API we need an AOI (The polygon of the location we need to capture). For that, we need the GeoJSON file (a format for encoding geographic data structures). There are several ways to create a Shapefile or a GeoJSON file and <a href="http://geojson.io/">geojson.io</a> is one such place. Save the GeoJSON to a file named <em>a</em><strong><em>oi.geojson .</em></strong></p><h4><strong>Now Let’s call the API</strong></h4><p>Create an account in the<strong> open access hub</strong> <a href="https://scihub.copernicus.eu/dhus/#/home">https://scihub.copernicus.eu/dhus/#/home</a></p><pre>#create instance of sentinal<br>api = SentinelAPI(&#39;username&#39;, &#39;password&#39;)<br><br>#Specify the path of geojson file<br>footprint = geojson_to_wkt(read_geojson(&#39;/content/aoi.geojson&#39;))<br><br>#Specify the data , satellite name on the query<br>products = api.query(footprint,<br>                     date = (&#39;NOW-100DAYS&#39;, &#39;NOW&#39; ),<br>                     platformname = &#39;Sentinel-2&#39;,<br>                     processinglevel = &#39;Level-2A&#39;,<br>                     cloudcoverpercentage = (0, 20))</pre><p>The code above will download the products related to that location and return some data that is stored in the <strong>products</strong> variable. We need to analyze the API further</p><h3>Processing the Data</h3><p>Convert the products to a geo data frame to analyze the result. For that, we will be using the below code</p><pre>gdf = api.to_geodataframe(products)<br>print(gdf.columns)</pre><p>The result of the above code consists of the following features. Based on these features we can analyze which type of image is needed to be downloaded.</p><pre>[&#39;title&#39;, &#39;link&#39;, &#39;link_alternative&#39;, &#39;link_icon&#39;, &#39;summary&#39;, &#39;ondemand&#39;,<br>       &#39;generationdate&#39;, &#39;beginposition&#39;, &#39;endposition&#39;, &#39;ingestiondate&#39;,<br>       &#39;orbitnumber&#39;, &#39;relativeorbitnumber&#39;, &#39;illuminationazimuthangle&#39;,<br>       &#39;illuminationzenithangle&#39;, &#39;vegetationpercentage&#39;,<br>       &#39;notvegetatedpercentage&#39;, &#39;waterpercentage&#39;, &#39;unclassifiedpercentage&#39;,<br>       &#39;mediumprobacloudspercentage&#39;, &#39;highprobacloudspercentage&#39;,<br>       &#39;snowicepercentage&#39;, &#39;cloudcoverpercentage&#39;, &#39;level1cpdiidentifier&#39;,<br>       &#39;format&#39;, &#39;processingbaseline&#39;, &#39;platformname&#39;, &#39;filename&#39;,<br>       &#39;instrumentname&#39;, &#39;instrumentshortname&#39;, &#39;size&#39;, &#39;s2datatakeid&#39;,<br>       &#39;producttype&#39;, &#39;platformidentifier&#39;, &#39;orbitdirection&#39;,<br>       &#39;platformserialidentifier&#39;, &#39;processinglevel&#39;, &#39;datastripidentifier&#39;,<br>       &#39;granuleidentifier&#39;, &#39;identifier&#39;, &#39;uuid&#39;, &#39;geometry&#39;]</pre><p>Here we can see various useful information like vegetation data, cloud cover, water content, etc of the AOI. I will be sorting the data based on the percentage of cloud coverage. As we know that we need images with less cloud coverage.</p><pre>gdf_sorted = gdf.sort_values([&#39;cloudcoverpercentage&#39;], ascending=[True])</pre><p>After this execution data frame will be displayed with less cloud coverage. The next part is downloading the exact image based on our preference. The download of any particular image needs a URL.So in the above result, we can see a feature called <strong>uuid</strong>. Copy the uuid and run the below code by replacing the uuid.</p><p><em>Note: The size of the image will be more than 500 MB as it contains all the metadata and various resolution</em></p><pre>#replace uuid<br>api.download(&quot;f197d3d4-c5db-451f-bfcf-04642599ee0f&quot;)</pre><p>This code will download a zip file consisting of the satellite image data and metadata in various resolutions. Let&#39;s explore the folder structure. Before that, please unzip the file</p><p>The dataset with all 13 bands of information. We will write the data of these three bands in an empty tiff file and mask AOI on it. Locate the folder named ‘R10’ and change the names of files in the code below accordingly.</p><pre>bands = r&#39;...\GRANULE\L2A_T18TWL_A025934_20200609T155403\IMG_DATA\R10m&#39;<br>blue = rasterio.open(bands+&#39;\T18TWL_20200609T154911_B02_10m.jp2&#39;) <br>green = rasterio.open(bands+&#39;\T18TWL_20200609T154911_B03_10m.jp2&#39;) <br>red = rasterio.open(bands+&#39;\T18TWL_20200609T154911_B04_10m.jp2&#39;) <br>with rasterio.open(&#39;image_name.tiff&#39;,&#39;w&#39;,driver=&#39;Gtiff&#39;, width=blue.width, height=blue.height, count=3, crs=blue.crs,transform=blue.transform, dtype=blue.dtypes[0]) as rgb:<br>    rgb.write(blue.read(1),3) <br>    rgb.write(green.read(1),2) <br>    rgb.write(red.read(1),1) <br>    rgb.close()</pre><p>The next step is to combine these 3 bands to make a single TIF file and visualize the image.</p><pre>sdata = rasterio.open(&quot;image_name.tiff&quot;)<br><br>from rasterio.plot import show<br>show(sdata)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc2d87d4b649" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Satellite Imagery Analysis, Part1]]></title>
            <link>https://medium.com/@prathyashjb/basics-of-satellite-imagery-analysis-part1-d06ee23ab703?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/d06ee23ab703</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Wed, 14 Jun 2023 09:58:26 GMT</pubDate>
            <atom:updated>2023-06-14T12:11:14.913Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article gives detailed information on satellite imagery as well as the various steps involved in analyzing the images.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TxPnzzUCtBG1L3gpGohgqw.jpeg" /></figure><h3>What’s inside Satellite images?</h3><p>Let’s do a simple comparison between normal images and satellite images. Normal images are images taken by a digital camera in our daily life. These photographs are made by the reflected rays of the spectrum in the visible region. In other words. Only the data regarding the visible spectrum is available in these types of photographs. Other spectrums like infrared, near-infrared, etc.. are not captured.</p><p>In the case of satellite images, cameras are capable of capturing a wide range of spectrums that a normal camera cannot achieve. For example, we need to find the temperature of an object present in the given image. The normal images fail this test. By employing the infrared region of the spectrum in satellite images, we can find the comparative temperature levels of objects in it.</p><h3><strong>Source for Satellite Images</strong></h3><p>If you have done any browsing regarding satellite imagery, I think that you will be seen some names like Landsat and Sentinel. Landsat satellites provide high-quality, multi-spectral imagery of the surface of the Earth. These moderate-resolution, remotely sensed images are not just pictures, but contain the visible and invisible light spectrum. Landsat satellites have the optimal ground resolution and spectral bands to efficiently track land use and to document land change due to climate change, urbanization, drought, wildfire, biomass changes (carbon assessments), and a host of other natural and human-caused changes.</p><p>Sentinel-2 multispectral sensor allows quality pictures of the terrain that can be implemented for land management, monitoring agriculture, and forestry.</p><h3>Spectrum Bands</h3><p>Sensors integrated into satellites are designed to acquire data in different ranges of frequencies along the electromagnetic spectrum. These ranges are called bands. These types of processes cannot be done using normal cameras. Many sensors on earth-observing satellites measure the amount of electromagnetic radiation (EMR) that is reflected or emitted from the Earth’s surface. These sensors, known as multispectral sensors, simultaneously measure data in multiple regions of the electromagnetic spectrum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*TnDFneLCfCJfXIPmulQ7ow.png" /><figcaption>Bands used in Landsat8</figcaption></figure><p>The bands above show will perform various applications like detecting vegetation, water content, roads, buildings, coastal areas, mineral and rock exploration, moisture sensing, etc.</p><p>Here I had taken Landsat for reference purposes only. The bands above mentioned can work on a combination level as well as an individual level based on the applications. The band combination of <strong>Landsat 8</strong> is mentioned below</p><h4>Natural Color (4, 3, 2)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*ESv5i9JOFKF92jc7J6cQfQ.png" /></figure><p>The natural color composite uses a band combination of red (4), green (3), and blue (2). It replicates close to what our human eyes can see. While healthy vegetation is green, unhealthy flora is brown. Urban features appear white and grey and water is dark blue or black.</p><h4>Color Infrared (5, 4, 3)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*e2XiBvYZne7Vdz-cvlRG2A.png" /></figure><p>This band combination is also called the near-infrared (NIR) composite. It uses near-infrared (5), red (4), and green (3). Because chlorophyll reflects near-infrared light, this band composition is useful for analyzing vegetation. In particular, areas in red have better vegetation health. Dark areas are water and urban areas are white.</p><h4>Short-Wave Infrared (7, 6 4)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*bphr_U-kGWs9aKcxiYyOyg.png" /></figure><p>The short-wave infrared band combination uses SWIR-2 (7), SWIR-1 (6), and red (4). This composite displays vegetation in shades of green. While darker shades of green indicate denser vegetation, sparse vegetation has lighter shades. Urban areas are blue and soils have various shades of brown.</p><h4>Agriculture (6, 5, 2)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*WJITrWvEphyVDB5Fo78Apw.png" /></figure><p>This band combination uses SWIR-1 (6), near-infrared (5), and blue (2). It’s commonly used for crop monitoring because of the use of short-wave and near-infrared. Healthy vegetation appears dark green. But bare earth has a magenta hue.</p><h4>Geology (7, 6, 2)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*nRV3-mry_DV_Ov9MfrtqFw.png" /></figure><p>The geology band combination uses SWIR-2 (7), SWIR-1 (6), and blue (2). This band combination is particularly useful for identifying geological formations, lithology features, and faults.</p><h4>Bathymetric (4, 3, 1)</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*TnUvg5zMbKGKarnzkowroA.png" /></figure><p>The bathymetric band combination (4,3,1) uses the red (4), green (3), and coastal bands to peak into water. The coastal band is useful in coastal, bathymetric, and aerosol studies because it reflects blues and violets. This band combination is good for estimating suspended sediment in the water.</p><p>I believe that you got an overview of the concepts of satellite imagery, image capturing, and composition. In the part 2 section, we will be focusing on the hands-on experience in the analyzing satellite image</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d06ee23ab703" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Object Detection using Tensor Flow Lite]]></title>
            <link>https://medium.com/@prathyashjb/custom-object-detection-using-tensor-flow-lite-8e4947537f4b?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e4947537f4b</guid>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Fri, 16 Dec 2022 14:51:51 GMT</pubDate>
            <atom:updated>2022-12-16T14:51:51.709Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Tensor Flow Lite Object Detection Training on Custom Dataset</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iou5RtnLnOsVP3V1mOMYVQ.png" /></figure><p><em>In this article , we walk through the steps to train and export a custom Tensor Flow Lite object detection model with custom dataset. Using this post , you will get a an experience to develop a model that is capable of detecting any type of object based on the dataset you train.</em></p><p>TensorFlow lite also provide pre-trained model for detecting various objects like person, cars, buses etc, these are done using transfer learning method. In this process no need of training required.</p><h4><strong>What is TensorFlow Lite?</strong></h4><p>TensorFlow Lite is an open-source, product ready, cross-platform deep learning framework that converts a per-trained model in TensorFlow to a special format that can be optimized for speed or storage.</p><p>The special format model can be deployed on edge devices like mobiles using <strong>Android</strong> or <strong>iOS</strong> or Linux based embedded devices like <strong>Raspberry Pi</strong> or <strong>Micro controllers</strong> to make the inference at the Edge.</p><h4>Requirement</h4><p><strong><em>Google Colab , Label Img</em></strong></p><p>For the development purpose I will be using <strong>Google Colab</strong> as the environment. So if you are new to Google Colab, please refer the video below to avoid troubles</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FRLYoEyIHL6A&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DRLYoEyIHL6A&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FRLYoEyIHL6A%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/e81d1369c52d9a58b46fad825fc9017b/href">https://medium.com/media/e81d1369c52d9a58b46fad825fc9017b/href</a></iframe><h3>Lets Build it !</h3><h4><strong>Step 1 : Prepare the Datasets</strong></h4><p>Datasets here used are downloaded from <strong>TensorFlow official site</strong>. In this dataset it consist of two classes 1 ) Pig Android 2) Green Android. So the model will detect only these type of images . If needed you can download dataset from the link below.</p><p><a href="https://storage.googleapis.com/download.tensorflow.org/data/android_figurine.zip">https://storage.googleapis.com/download.tensorflow.org/data/android_figurine.zip</a></p><p><strong>Note </strong>: If you are going with the same dataset I used here. You can skip the step 1.1 and 1.2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*e1Jn6kg6ytP2epjrWlrX-w.png" /><figcaption>Class: Green Android</figcaption></figure><p>If you are planning to do with your own dataset , you need to follow below all the steps I mentioned.For example you have to detect dogs and cats, for this you need minimum 80 images of the both Dog and Cat class. Next step is the annotation process.</p><p><strong>Step 1.1 ) Image Annotation</strong></p><p>Open the Label Img app. On the left tab you need to select <strong>Open Dir</strong> to select the folder where your datasets is located.</p><p>Also set the saving directory as per your need, for that select <strong>Change Save Dir . </strong>Once you finished this part , next thing is to annotate the object in the picture.</p><p>For understanding image annotation you can follow the steps shown in below video . In this tutorial I am using a dataset which is already annotated. So I will not be showing the annotation part.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F3d_EffmnAQc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D3d_EffmnAQc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F3d_EffmnAQc%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/23cfccc1326c4ba7701c2285ba5dee8b/href">https://medium.com/media/23cfccc1326c4ba7701c2285ba5dee8b/href</a></iframe><p>After watching the video you will get a brief idea about image annotation. By the completion of annotation step your folder should contain two file types <strong>image </strong>and <strong>XML</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/128/1*0bK8jXdgf2vtY-0cHdA7rg.png" /><figcaption>Dataset folder after annotation</figcaption></figure><p><strong>Step 1.2 ) Dataset Splitting</strong></p><p>After successful annotation (Step 1.1) of your images in the folder, you will get a folder containing the <strong>images </strong>and corresponding <strong>XML </strong>file of each images.</p><p>The next step is to split the dataset into two folder <strong>train</strong> and <strong>val. </strong>While splitting into test ,val folder ensure that you splitting must be in following pattern. <strong>Train </strong>folder must contain<strong> 80%</strong> of the full dataset and <strong>Val </strong>folder should contain rest <strong>20%. </strong>In both the folder the classes (cat class / dog class ) must be equally copied</p><p>Create two folder named <strong>Train </strong>and <strong>Val </strong>and move the images and corresponding XML in the ratio given above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/1*p1b7bndBWTOrYOSBN7fH1Q.png" /><figcaption>In my case the folder look likes this</figcaption></figure><p><strong>Note : While splitting corresponding individual XML file should also be selected for move operation.</strong></p><blockquote>You are ready for developing the architecture !!</blockquote><h4>Step 2: Building the Detection Model</h4><p><strong>Step 2.1 ) Upload Annotated Dataset.</strong></p><p>Create a folder in your google drive called “Datasets” or any thing you want. Upload the <strong>Train </strong>folder and <strong>Val </strong>folder in the created folder.</p><p><strong>Step 2.2 ) Open Google Colab</strong></p><p>Change the runtime to GPU, For that select <strong>Runtime&gt; Change runtime type </strong>from the top bar.</p><p>Step 2.3) <strong>Import dataset to Colab (</strong>if you are using your own dataset<strong>)</strong></p><pre>from google.colab import drive<br>drive.mount(&#39;/content/gdrive/&#39;, force_remount=True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*tBMhmqjFCJ4y0fGtnl0t2A.png" /></figure><p>After executing the above code your drive ill be automatically mounted to google colab. Now you will be able to see the content in your drive. In my case it look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*tX0P8CC8cUCPTsUiw-S6Rg.png" /><figcaption>Drive mounted on Colab</figcaption></figure><p>Open the <strong>My Drive,</strong> you will see the folder that you created for uploading Train and Val folder.</p><p>After locating the folder. You need to add the location of <strong>Train </strong>and <strong>Val </strong>Folder in the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*MNEnj6YvuwTIfhsm4LUX9A.png" /></figure><p>You need to change the label according to the classes you annotated.</p><p>Complete source code for the object detection is attached below.</p><p><a href="https://colab.research.google.com/drive/1TzjnagZZths9TfHHnrtzlbn3qFWu23_y?usp=sharing"><strong>https://colab.research.google.com/drive/1TzjnagZZths9TfHHnrtzlbn3qFWu23_y?usp=sharing</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e4947537f4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create CRUD API Using Golang and MongoDB]]></title>
            <link>https://medium.com/@prathyashjb/create-crud-api-using-golang-and-mongodb-2daa8404f04?source=rss-ad2fc3e7de3d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2daa8404f04</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[api-integration]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Prathyash Joy Binu]]></dc:creator>
            <pubDate>Sat, 03 Apr 2021 18:08:32 GMT</pubDate>
            <atom:updated>2021-04-03T18:08:32.948Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PCbQAt3WCDcTns1YFlN_mQ.png" /></figure><p>In this tutorial we will learn how to create a CRUD API using Golang and MongoDB. Here we will be get familiarized with operations like add, update, delete, read. So lets move..</p><h3>Prerequisites</h3><p>We assume that you already have the latest version of Go Installed, If doesn’t have go installed. Check out this doc for installation <a href="https://golang.org/doc/install">https://golang.org/doc/install</a></p><h3>Getting Started</h3><p>Firstly we need to create a project folder called <strong>restfulAPI. </strong>So open VS code editor and type the following command in the terminal to create folder.</p><pre>$ mkdir restfulAPI<br><strong>$</strong> cd restfulAPI</pre><p>Create a file called <strong>main.go</strong> using <strong>File&gt;New</strong> option in VS code or use the below command in the terminal</p><pre><strong>$</strong> touch main.go</pre><p>After this you will see a file named <strong>main.go </strong>is opened in the VS code. To verify whether everything goes file , lets create a sample program.</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>func main() {<br>    fmt.Println(&quot;Hello World&quot;)<br>}</pre><p>To run your sample code run the following command.</p><pre><strong>$</strong> go run main.go</pre><p>If there is no error occurred you will get an output shown below.</p><p><strong>Expected Output</strong></p><pre><strong>$ Hello World</strong></pre><p>Everything is going perfect. So lets move to our API development</p><h3>Project Folder Structure</h3><p>Inside our <strong>restfulAPI</strong> folder, we have another three sub folders.Please create these folder below the project folder.</p><ol><li><strong>dbhelper :</strong> Folder contains code which establish connection with MongoDB</li><li><strong>models: </strong>Contains the models needed</li><li><strong>operations: </strong>All the code of operations like add, update, read, delete are attached here</li></ol><h3>Step 1: Create Routes ,HTTP Handler using Gorilla Mux</h3><p>Package gorilla/mux implements a request router and dispatcher for matching incoming requests to their respective handler.</p><p>For using gorilla mux package ,firstly we need to to import it.</p><pre>go get github.com/gorilla/mux</pre><p>So lets create routes for serving the requests. Open the main.go file and paste the code</p><p><em>main.go</em></p><pre>package main<br><br>import (<br>   &quot;restfulAPI/dbhelper&quot;<br>   &quot;restfulAPI/operations&quot;<br>   &quot;github.com/gorilla/mux&quot;<br>   &quot;log&quot;<br>   &quot;net/http&quot;<br>   &quot;os&quot;<br>)<br><br>var ApiRouter = mux.NewRouter()<br><br><br>func main() {<br>// HTTP Serving Code will be attached</pre><pre>PortActivation()<br>}<br><br><br>func PortActivation() {<br>   port := os.Getenv(&quot;PORT NO&quot;)<br>   if port == &quot;&quot; {<br>      port = &quot;8080&quot;<br>      log.Printf(&quot;API to port %s&quot;, port)<br>   }<br><br>   log.Printf(&quot; API Listening on port %s&quot;, port)<br>   if err := http.ListenAndServe(&quot;:&quot;+port, ApiRouter); err != nil {<br>      log.Fatal(err)<br>   }<br>}</pre><h3>Step 2: Setting Up Basic CRUD Operations</h3><p>Open<strong> operations</strong> folder and create a file called <strong>crudoperations.go</strong>. Here we will create endpoints for the operations like read, add, update,delete. In this section we will only setup the basic structure of the endpoint for various CRUD operations.</p><ul><li><em>crudoperations.go</em></li></ul><pre>package operations<br><br>import (<br>   &quot;encoding/json&quot;<br>   &quot;net/http&quot;<br>)<br><br><br>// API Starting End point<br>func APIhitpoint(w http.ResponseWriter, r* http.Request){<br>   json.NewEncoder(w).Encode(&quot;API Service Started&quot;)<br>}<br><br>//Read End point<br>func ReadData(w http.ResponseWriter, r* http.Request){<br>   json.NewEncoder(w).Encode(&quot;Read API Routing&quot;)<br>}<br>//Add End point<br>func AddData(w http.ResponseWriter, r* http.Request){<br>   json.NewEncoder(w).Encode(&quot;Add API Routing&quot;)<br>}<br>//Update End Point<br>func UpdateData(w http.ResponseWriter, r* http.Request){<br>   json.NewEncoder(w).Encode(&quot;Update API Routing&quot;)<br>}<br>//Delete Endpoint<br>func DeleteData(w http.ResponseWriter, r* http.Request){<br>   json.NewEncoder(w).Encode(&quot;Delete API Routing&quot;)<br>}</pre><p>After creating the basic structure of the endpoint, we need to specify the routes for these endpoints, for that open <strong>main.go</strong> and paste the code in the main function block.</p><pre>ApiRouter.HandleFunc(&quot;/&quot;, operations.APIhitpoint)<br>ApiRouter.HandleFunc(&quot;/ReadData&quot;, operations.ReadData)<br>ApiRouter.HandleFunc(&quot;/AddData&quot;, operations.AddData)<br>ApiRouter.HandleFunc(&quot;/UpdateData&quot;, operations.UpdateData)<br>ApiRouter.HandleFunc(&quot;/DeleteData&quot;, operations.DeleteData)</pre><p>Full code of main.go</p><p><em>main.go</em></p><pre>package main<br><br>import (<br>   &quot;github.com/gorilla/mux&quot;<br>   &quot;log&quot;<br>   &quot;net/http&quot;<br>   &quot;os&quot;<br>   &quot;restful -API/operation&quot;<br>)<br><br>var ApiRouter = mux.NewRouter()<br><br>func main() {<br>   ApiRouter.HandleFunc(&quot;/&quot;, operation.APIhitpoint)<br>   ApiRouter.HandleFunc(&quot;/ReadData&quot;, operation.ReadData)<br>   ApiRouter.HandleFunc(&quot;/AddData&quot;, operation.AddData)<br>   ApiRouter.HandleFunc(&quot;/UpdateData&quot;, operation.UpdateData)<br>   ApiRouter.HandleFunc(&quot;/DeleteData&quot;, operation.DeleteData)<br>PortActivation()<br>}<br><br>func PortActivation() {<br>   port := os.Getenv(&quot;PORT NO&quot;)<br>   if port == &quot;&quot; {<br>      port = &quot;8080&quot;<br>      log.Printf(&quot;API to port %s&quot;, port)<br>   }<br><br>   log.Printf(&quot; API Listening on port %s&quot;, port)<br>   if err := http.ListenAndServe(&quot;:&quot;+port, ApiRouter); err != nil {<br>      log.Fatal(err)<br>   }<br>}</pre><p>Run the main.go file using the command</p><pre><strong>$</strong> go run main.go</pre><p>After running ,open the browser and paste the link below</p><p><a href="http://localhost:8080/AddData">http://localhost:8080/</a></p><p><a href="http://localhost:8080/AddData">http://localhost:8080/ReadData</a></p><p><a href="http://localhost:8080/AddData">http://localhost:8080/AddData</a></p><p><a href="http://localhost:8080/AddData">http://localhost:8080/UpdateData</a></p><p><a href="http://localhost:8080/AddData">http://localhost:8080/DeleteData</a></p><p><strong>Expected Output</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g1Zp3sHCigCsVbATca4T4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BFcjplM28_i5kj969u8-VQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBKmhJ337FQCMkwMSYHp0w.png" /><figcaption>API Endpoints</figcaption></figure><p>If your output is similar to the output attached then the basic structure for CRUD API is done so far.</p><h3>Step 3: Establishing connection with MongoDB</h3><p>Import MongoDB package</p><pre>go get go.mongodb.org/mongo-driver</pre><p>After this open the folder <strong>dbhelper</strong> and create a file called <strong>connection.go</strong></p><p><em>connection.go</em></p><pre>package dbhelper<br><br>import (<br>   &quot;context&quot;<br>   &quot;fmt&quot;<br>   &quot;go.mongodb.org/mongo-driver/mongo&quot;<br>   &quot;go.mongodb.org/mongo-driver/mongo/options&quot;<br>   &quot;time&quot;<br>)<br><br>var Client *mongo.Client<br><br>func DBConnection(){<br>   fmt.Print(&quot;DB connecting&quot;)<br>   ctx,_ := context.WithTimeout(context.Background(),10*time.<em>Second</em>)<br>   clientOption := options.Client().ApplyURI(&quot;mongodb://localhost:27017&quot;)<br>   Client,_= mongo.Connect(ctx,clientOption)<br>}<br></pre><p>Run the main.go, if there is no error MongoDB connection is successfully established</p><p>So we have successfully completed our basic structure for a CRUD API.</p><p>For proceeding to next step you have to install Postman from the link <a href="https://www.postman.com/">https://www.postman.com/</a>. This is a popular API client that makes it easy for developers to create, share, test and document APIs.</p><p>For final part please wait………..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2daa8404f04" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>