<?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 AJith RaJ on Medium]]></title>
        <description><![CDATA[Stories by AJith RaJ on Medium]]></description>
        <link>https://medium.com/@ajithraj_gangadharan?source=rss-51f3b2938b07------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*9dxnbmo2NaYxca8AKsvbcw.jpeg</url>
            <title>Stories by AJith RaJ on Medium</title>
            <link>https://medium.com/@ajithraj_gangadharan?source=rss-51f3b2938b07------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 00:15:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ajithraj_gangadharan/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[Leveraging AI for Fisheries Resource Management]]></title>
            <link>https://medium.com/@ajithraj_gangadharan/leveraging-ai-for-fisheries-resource-management-6f83d33a339b?source=rss-51f3b2938b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f83d33a339b</guid>
            <category><![CDATA[automotive]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[cnn]]></category>
            <category><![CDATA[yolo]]></category>
            <category><![CDATA[fisheries]]></category>
            <dc:creator><![CDATA[AJith RaJ]]></dc:creator>
            <pubDate>Mon, 19 Oct 2020 20:08:10 GMT</pubDate>
            <atom:updated>2020-10-20T10:19:42.461Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7gqHbGiYe8i82uEldxCDiw.png" /><figcaption>Fish4KnowledgeDataset</figcaption></figure><p>The image is from Fish4Knowledge public dataset. The scientific classification of a fish into its respective kingdom, phylum, class, order, suborder, family is a rather cumbersome process, and can generally be only done by the ocean science experts after detailed analysis from the image/video data, thereby making the research for fisheries resource management tedious and exorbitant.</p><p>A few decades back the automotive industry also faced a similar challenge, it could develop sensors to detect objects, but those sensors weren’t able to classify or differentiate between a human and static/dynamic object in the environment. For example., the Radar which was the one of the first sensors added to the cars for Advanced Driver Assistance system (ADAS) features was able to detect objects within a specified range, but it couldn’t differentiate a human from a mailbox on road curbs. The recent advancements(Artificial Intelligence) in the software field have however enabled the data from the sensors like camera, lidar, and radar to be transformed into 2D(images) and 3D(point cloud-photogrammetry) which can be used for classifying the objects into classes like human, cyclists, cars, trucks, and traffic signs. These advancements fueled the growth spurt in the autonomous driving industry, with car companies like Tesla supporting almost fully autonomous driving in highways (SAE Level 3 compliant) being launched into the markets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RBM5qlHK_f-CyEWySYopXg.png" /><figcaption>Source: Tesla</figcaption></figure><p>A similar shift is now coming to the maritime community, where instead of introducing a radical new technology, the current competence can be improved by augmenting the current data with Deep learning which is a subset of Artificial Intelligence. And the most compelling reason of why it could be a game changer is that it won’t require much from the current data collection infrastructure. The most crucial part behind deep learning is the data, which currently only requires a camera as a sensor for collecting the 2D image data. And since mostly every local area has its own exclusive marine ecosystem, the camera can be hermetically sealed and used in boats/ships structures and fishing nets to collect data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*32QHoA3chwx3n8ZtnAu7_w.png" /><figcaption>Development Phases</figcaption></figure><p>There are 2 popular ways of conducting the fish identification research- online and offline analysis. In online analysis, the live video data from the camera fitted on the boat or the fishing net needs to be processed in real-time to produce the results, which would require object detection, tracking and classification. Object detection involves distinguishing foreground fish from the ocean background captured in the video, which basically implies identifying the fish from static objects. Tracking involves predicting and mapping the trajectory of the fish movement, and Classification deals with association of fish into their respective scientific classification. Offline analysis involves most of the same routine, but with a different strategy for data collection. Instead of adding the camera/recording device on the boat/fish, the sensor can be fitted on the ocean/water body surface or routinely collected data from AUV/ROVs underwater scans of the local region. The data collected periodically can be analyzed using deep learning to understand the balance of species, along with data about underwater plants which also indicates the health of the marine ecosystem. Currently the best online dataset for offline analysis is the Fish4Knowledge dataset from the Lake of Taiwan collected between 2010–13.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*6g70HpTDDeNe1eFDXKUfkw.gif" /><figcaption>YOLO Detection &amp; Classification on a traffic heavy intersection</figcaption></figure><p>There are also many challenges while designing an analysis model for underwater image data due to variations in luminosity, murkiness, shape distortion during fish movement, unwarranted occlusions, and many others which pose a hindrance for developing a robust system. But with more training data, and experience in data collection these issues can be mitigated. For testing the viability of these software techniques, a virtual test bench can be setup, which would contain Image data from the local water bodies. The randomly selected image data can then be segregated into training dataset compromising of 75% of overall image data, in which we can split the training dataset into 80% training and 20% validation. Validation dataset is used to validate the results of model in training phase, and retraining based on its errors. And the remaining 25% of the isolated image data can be used to test the accuracy of the model. For proof of concept phase, the best model to start with would be the LeNet-5, which is a Convolutional Neural Network(CNN) which is used in many applications such as digits recognition, traffic sign recognition and many more. This accuracy can be increased with more sophisticated models like the YOLO which is also used in Object detection in autonomous vehicles. Much of the research in this domain has been conducted in the past 5 years, and their results look very promising. For example, the offline analysis of Fish4Knowledge dataset based on YOLO (Deep Learning Model) has provided researchers from Australia and Pakistan the detection accuracy of above 90% which is almost comparable to human analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EsuGr4BO1JrsR5BfwuKnIA.png" /><figcaption>Results from ongoing research for detection and tracking</figcaption></figure><p>For generating more awareness to fish identification techniques, the data collected from the local waterbodies can be made public with proper annotations and labels which can be used for building models and conducting competitions to encourage researchers to find best models which suit our local ecosystems. And for the future scope, we can again draw parallels from the automotive industry because when the baseline for 2D detection and classification is achieved for fish identification, then the research can advance to sensor fusion of bathymetric lidar and camera images for underwater 3D detection and classification.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f83d33a339b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Euclidean Clustering for Lidar point cloud data]]></title>
            <link>https://medium.com/@ajithraj_gangadharan/euclidean-clustering-for-lidar-point-cloud-data-8603f266b246?source=rss-51f3b2938b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/8603f266b246</guid>
            <category><![CDATA[udacity]]></category>
            <category><![CDATA[sensor-fusion]]></category>
            <category><![CDATA[autonomous-vehicles]]></category>
            <category><![CDATA[clustering]]></category>
            <dc:creator><![CDATA[AJith RaJ]]></dc:creator>
            <pubDate>Sun, 28 Jun 2020 20:34:21 GMT</pubDate>
            <atom:updated>2020-06-28T21:07:26.466Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article you will get to know how to cluster the point cloud data to locate and cluster objects which can be later classified into obstacles, traffic signs, vehicles, pedestrians, etc.</p><p>Before clustering the point cloud data, the data is first filtered and segmented generally using voxel filtering, and ransac based segmentation. To know more about these you can check my previous article <a href="https://medium.com/@ajithraj_gangadharan/3d-ransac-algorithm-for-lidar-pcd-segmentation-315d2a51351">here</a>.</p><h3><strong>Data Structure for Storing 3D PCD points — KDTree</strong></h3><p>The first thing which comes to the mind of a developer before building a clustering algorithm would be to first create a optimized data structure for storing the points of the point cloud data(pcd) for easy search and retrieval.</p><p>Although python offers lot of data structures like dictionary, tuples, lists, collections, etc. <strong><em>KDTree</em> </strong>was preferred because of its speed and performance characteristics for handling large amounts of data, and inherent data partitioning nature which is very useful while calculating the nearest neighbor points.</p><p>So you can choose to use <a href="https://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KDTree.html">sklearn implementation </a>of <em>KDtree</em>, but for the purpose of this application, I chose to implement my own <em>Kdtree</em> structure because I could build highly customized version of it, plus it was a great learning experience as well.</p><p>The most rudimentary definition I could think of a <em>KDtree</em> is that, its a structure of nodes which are interlinked sequentially together based on their properties, the arrangements of nodes is similar to that of a Tree structure in K dimensions, which makes it efficient to search for neighboring points. A more technical definition of a <em>KDtree</em> can be found <a href="https://en.wikipedia.org/wiki/K-d_tree">here</a>. The below example shows the definition of a <em>KDtree </em>node, the node contains <em>point</em> coordinates and <em>point id</em>. The <em>left_node </em>and <em>right_node</em> point to the other interlinked nodes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a9a5b2dabd76d04416304e04e1c29938/href">https://medium.com/media/a9a5b2dabd76d04416304e04e1c29938/href</a></iframe><p>So now we know what are nodes, we know the underlying building blocks. Let’s go ahead and build the <em>KDTree</em>.</p><blockquote><strong><em>Line 10:16 — insert_points method</em></strong></blockquote><p>The constructor variable <em>root </em>refers to the first node<em>. </em>Inputs include a <em>pcd_dataframe </em>— x,y,z points arranged as columns), and <em>display_output_flag </em>which enables the display of all the points with the depth information.(store in kdtree_display_dict). We are iterating through each row containing a point which is given as an input to the <em>build_kdtree</em> method. And if the <em>display_output_flag is enabled, </em>it will call the method which will store the nodes and in <em>kdtree_display_dict, and </em>display the data inside the <em>Kdtree</em>(<em>preorder traversal-root, left right</em>).</p><blockquote><strong><em>Lines 28:50 — build_kdtree method</em></strong></blockquote><p>This method is quite straightforward:<br><em>Step 1</em>. Check if the current node being passed is empty.<br><em>Step 2</em>. If the current node is empty then create and return a node.<br><em>Step 3</em>. If the current node is not empty, then check if the current point being passed is less than the point data stored in the current node.<br><em>Step 4</em>. Call the <em>build_kdtree</em> method, but adding the current point as a right node with an incremented depth level.(X →Y →Z).<br><em>Step 5</em>. Step 4 should create a new node added to the right side of the current node.<br><em>Step 6</em>. If the conditions are not satisfied at Step 3, then repeat Step 4 but with keeping the left node instead of the right one.<br><em>Step 7</em>. Step 5 should create a new node added to the left side of the current node.</p><p>When this method is run iteratively will automatically check the points data to recursively build a <em>KDtree</em> structure.</p><blockquote><strong>Lines 52:86</strong>—search_elements method</blockquote><p>This method finds the nodes which are near to each other based on their Euclidean distance(<em>straight-line distance between two points</em>). We ensure that that the depth always stays in the range (0,1,2) by adding the modulo operator in Line 80. To find the nodes near our <em>search_point </em>we use a <em>distance_threshold </em>input<em> </em>parameter. In lines 84–86. We are basically checking if the current node that we are at is within the point is within the limits by checking the following conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*dgaWu-a2MRAA5YMtTu-H6g.png" /><figcaption>Checking if current node point (x,y,z) falling within the limts</figcaption></figure><p>If the conditions are satisfied then the Euclidean distance between the <em>search_point</em> and the <em>current_node</em> point is calculated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lyKYCS4-H8bG9fB9MYjivg.png" /><figcaption>Distance between <em>search_point </em>and current_node point</figcaption></figure><p>If the Euclidean distance is within the <em>distance_threshold </em>limit we add this point as a near point in <em>kdtree_search_results. </em>Then we recursively iterate through the left and the right node of the current node to find all the related points which is implemented by the search conditions in lines 97–104. For using the method we always provide the root node as an input while using in our application, this ensures that we go through all the nodes and cover all the points which are within the search limits in a much faster mechanism instead of covering all points in a conventional data structure.</p><blockquote><strong><em>Lines 88–121 — </em></strong><em>kdtree_display_dict(</em>optional)</blockquote><p>Stores the depthwise KDtree elements. Useful while debugging.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ad03e2e1b86e9a21fdcd580ea1435bf/href">https://medium.com/media/4ad03e2e1b86e9a21fdcd580ea1435bf/href</a></iframe><h3><strong>Euclidean Cluster Application Code</strong></h3><blockquote><strong>Lines 66–96 —</strong> find_clusters method</blockquote><p>Before running the eponymous method, a <em>KDtree</em> is build in the<em> __init__</em> method. Initially every point is assigned a <em>processed_flag_ </em>with a default value of False, and when the point is processed its changed to True. If the point is not processed before, it’s assigned as a new cluster and all the nearby points to the cluster is found by the <em>search_elements </em>method<em>. </em>All the points returned are then recursively iterated again through the <em>find_clusters </em>method, to check if they are part of another cluster and to verify if the nearby points have not been processed before.</p><blockquote><strong>Lines 31–54 —</strong> euclidean_clustering method</blockquote><p>In this method each we iterate through all the points in the pcd file, and call the <em>find_clusters </em>method to create new clusters and then check if the cluster satisfies the <em>min_size </em>parameter. (<em>max_size is not considered as it doesn’t make sense while clustering for segregating large objects</em>)</p><blockquote><strong>Lines 98- 129 —</strong> visualize_clusters method</blockquote><p>Matplotlib and seaborn libraries work well for 2D plots, but for 3D visualization, according to my personal preference, I would choose <strong>plotly </strong>over any other library. The plots have a very simplistic UI and intuitive interactivity features. In the final plot we draw the all the points in the pcd file and then overlay all the cluster points on top of them.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3104a66815ce441068b607315145168e/href">https://medium.com/media/3104a66815ce441068b607315145168e/href</a></iframe><blockquote><strong>Final Results</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*v5oviHaLP_GJqdwxf3OfAw.png" /><figcaption>3D Visualization of clusters identified(marked with different colors)</figcaption></figure><p>This is how the final results looks like, we have a 3D point cloud scan, with limited number of scan-points because we haven’t segmented the ground plane, and we have also limited the number of points as python causes a max recursive depth exception which can be handled in the code, but which is not required for explaining the core concepts of Euclidean clustering. Feel free to tinker around with the code, and modify the parameters to get different results. For a real time implementation I would strongly recommend the C++, which you can find <a href="https://github.com/ajith3530/Python_EUCLIDEAN_clustering">here</a>.</p><p>If you liked my explanation and found it useful to understand Euclidean clustering and its core concepts please don’t be shy to star my repository in <a href="https://github.com/ajith3530">GitHub </a>and generously add claps.</p><blockquote><strong>References</strong></blockquote><p><a href="http://www.udacity.com/">www.udacity.com</a> — Sensor Fusion Course</p><p><a href="https://plotly.com/python/3d-scatter-plots/">www.plotly.com</a> — 3D Scatter plot visualizations</p><p><a href="https://github.com/ajith3530/Python_EUCLIDEAN_clustering">https://github.com/ajith3530/Python_EUCLIDEAN_clustering</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8603f266b246" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3D RANSAC Algorithm for Lidar PCD Segmentation]]></title>
            <link>https://medium.com/@ajithraj_gangadharan/3d-ransac-algorithm-for-lidar-pcd-segmentation-315d2a51351?source=rss-51f3b2938b07------2</link>
            <guid isPermaLink="false">https://medium.com/p/315d2a51351</guid>
            <category><![CDATA[udacity]]></category>
            <category><![CDATA[lidar]]></category>
            <category><![CDATA[autonomous-driving]]></category>
            <category><![CDATA[obstacle-avoidance]]></category>
            <category><![CDATA[sensor-fusion]]></category>
            <dc:creator><![CDATA[AJith RaJ]]></dc:creator>
            <pubDate>Fri, 05 Jun 2020 22:57:05 GMT</pubDate>
            <atom:updated>2020-06-05T23:16:50.106Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*Bl0jbKc5FUZTaPxJPfop_Q.gif" /><figcaption>Udacity-SensorFusion-Lidar-PCD</figcaption></figure><h3>Theory of RANSAC</h3><p><strong>RANSAC</strong> stands for <strong>RAN</strong>dom <strong>S</strong>ampling and <strong>C</strong>onsensus. Its a robust model fitting algorithm, and its performance is often compared to that of the Linear Regression algorithm. <br>In this case, we are going to use RANSAC algorithm on Lidar point cloud(pcd) data to segment the ground plane from the other planes which could consist of vehicles, traffic-lights, or anything above the ground plane which needs to be classified for avoiding collision or for trajectory planning.</p><p>In this particular application RANSAC is preferred for ground plane segmentation due to inherent property to reject outliers. <em>(Outliers can be considered as unusual observations which are likely to be rejected)</em></p><p>The core algorithm is fairly straightforward.<br>Step 1 :: Select a random set of points(3 points for a forming a plane)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*C9tEQNjhCsT5-pvez8aIOA.png" /></figure><p>Step 2 :: Calculate the parameters required for the plane equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*uUDqCRcI_qrdEGsSDrJGtQ.png" /><figcaption>3D Plane equations for 3 non-collinear points</figcaption></figure><p>Step 3 :: Calculate the deviation of all the points in the point cloud from the plane using a distance estimate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*TpEYMIHtXmdqgdvtO-bhbQ.png" /></figure><p>Step 4 :: If the distance is within the THRESHOLD then add the point as an inlier.<br>Step 5 :: Store the plane points and points having the maximum number of inliers.<br>Step6:: Repeat the process again for MAX_ITERATIONS</p><p>After the RANSAC processing is complete, the plane having the maximum number of inliers is the best estimate of the ground plane. Any points cluster above this ground plane can be classified as an object, obstacle or traffic signs.</p><h3>Practical Implementation of RANSAC in Python</h3><p>The libraries required for running the RANSAC algorithm in python</p><pre>import pandas as pd<br>import matplotlib.pyplot as plt<br>import random<br>import math<br>from mpl_toolkits.mplot3d import Axes3D<br>import open3d as o3d</pre><p>Create a class for implementing RANSAC.</p><p>The 3 inputs required for implementing a basic RANSAC algorithm are:</p><ol><li>The point cloud data (in either pcd or ASCII)</li><li>MAX_ITERATIONS, as described in Step 6 of the logic.</li><li>THRESHOLD, as described in Step 4 of the logic.</li></ol><pre>class RANSAC:<br>    <em>&quot;&quot;&quot;<br>    RANSAC Class<br>    &quot;&quot;&quot;<br>    </em>def __init__(self, point_cloud, max_iterations,            <br>                 distance_ratio_threshold):<br>        self.point_cloud = point_cloud<br>        self.max_iterations = max_iterations<br>        self.distance_ratio_threshold = distance_ratio_threshold<br></pre><p>The RANSAC logic implementation can be found below:</p><p><strong>Lines 7–15</strong> — Creating a storage set of inliers_results, this is index of all points which are considered as inliers. A SET data structure is preferred to automatically remove the duplicate indexes generated. 3 Random points are generated for every iteration for creating the plane to find the inliers.</p><p><strong>Lines 17–33</strong> — These lines correspond to fetching the point data from the pcd/ASCII file format. This might change based on the format of the input data. In my case, in the ASCII file I had rows containing data like (x,y,z,R,G,B), so I don’t care about the R,G,B values. In the pcd file the data format was directly (x,y,z). I load the point cloud data as pandas dataframe so you can see some methods like .loc which fetch the data from a particular index location.</p><p><strong>Lines 35–55 — </strong>In this section we are iterating through all the points in the point cloud, and trying to find inliers for the plane that we just generated through random points. Needless to say, we don’t want to consider the randomly generated points of the plane, so we don’t use them by adding the conditional logic at Line 38. You can ignore the try and excepts block, since they are just trying to fetch the data based on the type of PCD data format. Once we have the point, we calculate the distance of that point from the plane that we generated based on the Cartesian formulae in the Step3. If the calculated distance is within the THRESHOLD then we consider it as an inlier. After every iteration in MAX_ITERATIONS limit we try to find the plane which has the maximum number of inliers through the logic in lines 53–55.</p><p><strong>Lines 58–70 — </strong>After getting the plane with the best count of inliers, we consider all the other points as outliers, and segregate and store them separately for visualization.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8768d84bc2252d94650a967f449a9bd/href">https://medium.com/media/d8768d84bc2252d94650a967f449a9bd/href</a></iframe><p>The complete code can be found <a href="https://github.com/ajith3530/Python_RANSAC"><strong>here</strong></a>.</p><p>Needless to say, the time taken for generating the ground plane depends on the MAX_ITERATION hyperparameter. The general execution speed is very slow when compared to the C++ implementation.</p><h3>Practical Implementation of RANSAC in C++</h3><p>You can find the C++ implementation of RANSAC along with k-D tree based clustering <a href="https://github.com/ajith3530/Udacity_Lidar_Obstacle_Detection"><strong>here</strong></a>. This was part of my Sensor fusion nanodegree from Udacity.</p><p><strong>Notes : </strong>If you want to use RANSAC for your projects, you can find its implementation in <a href="https://scikit-learn.org/stable/auto_examples/linear_model/plot_ransac.html">scikit-learn</a>. The RANSAC algorithm is available in linear_model with much more hyperparameters for optimization.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=315d2a51351" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>