<?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 Tina Chien on Medium]]></title>
        <description><![CDATA[Stories by Tina Chien on Medium]]></description>
        <link>https://medium.com/@tina-chien-tw?source=rss-ddd6e5d20164------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PUGUcb8W8nGFiTLrBtaMrw.jpeg</url>
            <title>Stories by Tina Chien on Medium</title>
            <link>https://medium.com/@tina-chien-tw?source=rss-ddd6e5d20164------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:47:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tina-chien-tw/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[Dog Breed Classification]]></title>
            <link>https://tina-chien-tw.medium.com/dog-breed-classification-2042e0cac262?source=rss-ddd6e5d20164------2</link>
            <guid isPermaLink="false">https://medium.com/p/2042e0cac262</guid>
            <category><![CDATA[dog-breed-classifier]]></category>
            <dc:creator><![CDATA[Tina Chien]]></dc:creator>
            <pubDate>Thu, 28 Oct 2021 13:29:08 GMT</pubDate>
            <atom:updated>2021-11-02T08:38:44.924Z</atom:updated>
            <content:encoded><![CDATA[<p>Do you like dogs? Have trouble telling which breed your neighbor&#39;s dog is? You can try my app to help you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CEw3efMk1sq-AW4TECpW2Q.png" /></figure><h3>1. Introduction</h3><p>In this project, I build a Convolutional Neural Network (CNN) to classify dog breeds with 92% accuracy. It can also detect a human and determine what kind of breed the person looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*8ysigK8aKQX3_xGpTCEjiA.png" /></figure><h4>Problem Statement</h4><p>The purpose of the project is to use a convolutional neural network (CNN) to distinguish dog breeds.</p><h4>Strategy to solve the problem</h4><ol><li>Use OpenCV to detect different Object, here is to detect human</li><li>Use pre-trained CNN to detect dogs. (Here, I used ResNet-50)</li><li>Create a CNN by myself from scratch to classify dog breeds</li><li>Use transfer learning to reduce training time</li><li>Use a mixed model which extracts features from the different pre-trained models.</li><li>Write the algorithm and evaluate it.</li></ol><h3>2. Data Exploration</h3><p>As you can see from the data set, there are 133 dog breeds and 8351 dog images, which were divided into training, validation, and test group. For human data, there are 13233 images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*LGnFowxscB2uYVNJIySZ7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*qbvH7bP2yOpXAMnqkP5jiQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DAF_3ljqX8QwT7wDFx2aQ.png" /></figure><p>The dog breed distribution graph shows that the quantity of each breed is fairly even and balanced, so <strong>the models can be evaluated using an accuracy metric.</strong></p><h3><strong>3. Data Preprocessing</strong></h3><p>When using TensorFlow as backend, Keras CNNs require a 4D array (which we’ll also refer to as a 4D tensor) as input, with shape</p><p>(nb_samples,rows,columns,channels),</p><p>where nb_samples corresponds to the total number of images (or samples), and rows, columns, and channels correspond to the number of rows, columns, and channels for each image, respectively.</p><p>The path_to_tensor the function below takes a string-valued file path to a color image as input and returns a 4D tensor suitable for supplying to a Keras CNN. The function first loads the image and resizes it to a square image that is 224×224224×224 pixels. Next, the image is converted to an array, which is then resized to a 4D tensor. In this case, since we are working with color images, each image has three channels. Likewise, since we are processing a single image (or sample), the returned tensor will always have shape</p><p>(1,224,224,3).</p><p>The paths_to_tensor function takes a numpy array of string-valued image paths as input and returns a 4D tensor with shape</p><p>(nb_samples,224,224,3).</p><p>Here, nb_samples is the number of samples, or number of images, in the supplied array of image paths. It is best to think of nb_samples as the number of 3D tensors (where each 3D tensor corresponds to a different image) in your dataset!</p><p>Getting the 4D tensor ready for ResNet-50, and for any other pre-trained model in Keras, requires some additional processing. First, the RGB image is converted to BGR by reordering the channels. All pre-trained models have the additional normalization step that the mean pixel must be subtracted from every pixel in each image. This is implemented in the imported function preprocess_input. Then rescaled the images by dividing every pixel in every image by 255.</p><h4>Detect Humans</h4><p>We use OpenCV’s implementation of <a href="http://docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html">Haar feature-based cascade classifiers</a> to detect human faces in images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*evtoDqbPCrkPB2tCjzkiFg.png" /></figure><h4>Detect Dogs</h4><p>Use a pre-trained <a href="http://ethereon.github.io/netscope/#/gist/db945b393d40bfa26006">ResNet-50</a> model to detect dogs in images. Downloads ResNet-50 model, along with weights that have been trained on <a href="http://www.image-net.org/">ImageNet</a>. Then predict the category of the image with ResNet-50 to detect dogs.</p><h3>4. Implementation</h3><h4>Create a CNN to Classify Dog Breeds (from Scratch)</h4><p>I optimize the basic CNN structure by adding more convolution layers to make the model deeper. In between convolution layers, there are maxpooling layers as bridging to reduce the space. Before final output, I add a dropout layer to prevent overfitting. The scratch model worked better compared to the previous one. The test accuracy is 4.6651%</p><p>However, it is always good to use a pre-trained network for object recognition. You can get a variety of photo features by using them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OiF6a60cxRYZXw2Esg1fCw.png" /></figure><h3>5. Refinement:</h3><h4>1. Use a CNN to Classify Dog Breeds</h4><p>Train a CNN using transfer learning to reduce training time without sacrificing accuracy. I used the pre-trained VGG-16 model as a fixed feature extractor, got test accuracy: 69.0191%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*HzxRI1qHXjiVXla-_NiMBA.png" /><figcaption>VGG-16</figcaption></figure><h4>2. Create a CNN to Classify Dog Breeds (using Transfer Learning)</h4><p>Because I extract features from the data set from pre-trained models and create a simple deep net by combining those features, I have to compute the features by myself to fit the needs of different networks. I also created CNNs from each network to compare the accuracy with the mixed model.</p><ul><li>img_size varies according to the documentation of the pre-trained model. In my case, the largest image size requirement is the NasNetLarge model requires (331,331,3) for input shape. Keras documentation for all models: <a href="https://keras.io/api/applications/">https://keras.io/api/applications/</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aY9_WzaJ7Gd903_JNzANtw.png" /></figure><h4>3. Hyperparameter tuning</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*LqLpwCyZ_RdPMpjAa9XtHw.png" /></figure><h3>6. Model Evaluation and Validation</h3><p>As you can see, the mixed model has the highest test accuracy. 92 %, The individual pre-trained model accuracy is not as high as the mixed one. The test accuracy is 87% for the inception model, 90% for the Xception model, 83% for the NASNetLarge model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*3zcGDUKxdLNEGNgrtyGUEQ.png" /></figure><p>In the mixed model, the training accuracy reached 99%, The validation accuracy is lower (92%), and further, the test accuracy reached 92%, indicating the model is over-fitting to the training set.</p><h4>Mixed Model:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*b4xasDFdP5yEHmNoVjqbDA.png" /></figure><h4>Inception model:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*0gMgDqiZ1aVpsOuxV7YElg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*bY0mA4k7sAvHvHWn963vGA.png" /></figure><h4>Xception model:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*knkW7REA_Hsi8TSP12HUbw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*lsQjViEeH6znVpIA7rW9RA.png" /></figure><h4>NASNetLarge model:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/219/1*JG9tXQIey3U2Fb0UU1c0Fw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*Z6NRWI9WYbk_0dBctsCURg.png" /></figure><h4>Justification</h4><p>8351 dog images for a 133 classes problem, it’s not so many images to train. It is best to find more dog images or use the augmentations techniques to create more training data which allows the model to generalize better.</p><h3>7. Conclusion</h3><h4>Test Your Algorithm</h4><p>As a result, you can see from the predictions below, the clear pictures can be predicted correctly. But for photos that are not clear or fake dog pictures are expected wrong. There are some interesting results that if the image has both human &amp; dog, it will detect a human other than a dog. The mix-breed dog picture, Milly, was predicted with the wrong breed. She is actually a mix with labrador &amp; doodle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G1muVwIkYVHcyLQ34KqKOA.png" /><figcaption>clear dog picture</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SwutgY5W1qcMjIBTNVOZrw.png" /><figcaption>dog &amp; human</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sHWQyoyjawhXuGQCDVglsA.png" /><figcaption>mix breed dog (labrador &amp; doodle)</figcaption></figure><h4><strong>Reflection</strong></h4><p>The accuracy improved from 4% with a scratch CNN model to 69% by using transfer learning (VGG-16), which means the larger the image library is the better the accuracy will be. (Imagenet has 1.2 million images)</p><p>Every CNN model has its own strength, we can combine its strength by extracting features from the data set from pre-trained models and creating a deep net to achieve better accuracy.</p><h4>Improvements</h4><ul><li>Need more data: 8351 dog images for a 133 classes problem, it’s not so many images to train. It is best to find more dog images or use the augmentations techniques to create more train data.</li><li>More epochs: train for more epochs as validation loss is still decreasing</li><li>Other transfer learning models: So far I try combining 3 models, the test accuracy is 92%. If I combine more models, the accuracy might be even better.</li></ul><p>To see more about this project, see the link to my Github available <a href="https://github.com/tinachientw/DSND_Dog_Breed_Classification">here.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2042e0cac262" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting a higher salary as a software engineer]]></title>
            <link>https://tina-chien-tw.medium.com/getting-a-higher-salary-as-a-software-engineer-ef15822836c7?source=rss-ddd6e5d20164------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef15822836c7</guid>
            <category><![CDATA[job-hunting]]></category>
            <category><![CDATA[job-search]]></category>
            <category><![CDATA[software-jobs]]></category>
            <category><![CDATA[job-satisfaction]]></category>
            <category><![CDATA[salary]]></category>
            <dc:creator><![CDATA[Tina Chien]]></dc:creator>
            <pubDate>Tue, 30 Mar 2021 12:16:14 GMT</pubDate>
            <atom:updated>2021-03-30T13:24:01.507Z</atom:updated>
            <content:encoded><![CDATA[<h4>Let’s learn from the developers using Stack Overflow survey data.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HQ6vrmCmp-lMJqJCbiN58w.jpeg" /></figure><h3>Introduction</h3><p>It seems to be a common misconception that Software Engineers are incredibly wealthy individuals. However, It is not always true. According to the Stack Overflow survey data (One of the most popular Q&amp;A websites for programmers), location and experience will determine the salary. Let’s learn from developers all over the world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Saw33rYir4VjwaHkqvDO_g.png" /></figure><h3>Where should you find a job?</h3><p>As a software engineer, you may have heard statements like “go to Silicon Valley, there are many startups” or “Asia has more opportunities now .” Everyone has different opinions; that why knowing the job market and the trends are significant.</p><p>Therefore, in this project, I used the Stack Overflow data from 2020 to analyze the global developer job market.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*Qm1RE66yQ_KqgEPASLeBlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*vkhpNBoMX1YeAbgcf83jOw.png" /></figure><p>As you can see from the diagrams above, a programmer’s salary in North America is much higher than those in Europe, Aisa, and other world areas, Even though Europe has more developers than others.</p><h3>Does experience matter?</h3><p>In general, programmers’ salaries grow with their experiences. However, developers in North America have a higher salary as junior developers than those in other areas. Even developers outside of North America have more than 20 years of experience; their salaries are still lower than junior developers in North America.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*-LZdV66w5-x-D-Zmu077yg.png" /></figure><p>In terms of job satisfaction, people in North America have higher scores in the first 20 years of experience.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*HcmOWFj0rzL3_yvDo57_JA.png" /></figure><h3>As a female developer, will people have sex bias?</h3><p>As a female developer, you might hear these statements like “Girls are not good in STEM” or “Male developers have higher salaries.” In fact, female developers have equal opportunities, no matter where you are and how much experience you have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*VvGEKdcB5fX42dYW878rMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*9ZdFhgUzLLPN0QkOzIY3kA.png" /></figure><h3>Does formal education play a big role in the job market? Which major is the best one from the developer’s point of view?</h3><p>Can everyone be a developer? Should I get a formal education to be a software engineer? These are the questions I have heard from many of my friends. As you can see from the chart below, people from different backgrounds can be excellent developers. Therefore, no matter which major you are in, you are welcome to join the IT field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1003/1*JT38oN3zSgEflyCvI_bJVQ.png" /></figure><p>However, if you want to pursue a higher income, getting a master&#39;s degree or a Ph.D. degree will definitely help.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*bOkAxplJCJRK1zYhHvGsAw.png" /></figure><h3>The Most Popular Languages Over the past 5 Years.</h3><p>Are you ready to be a developer? Let’s find out what you can do to prepare yourself.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*QpTDPOQlZrsuGVkNSqoSyw.png" /></figure><p>Java is the most popular language over the past 5 years. Even though the demand for Java is declining and python is getting more popular. Java, C, JavaScript is the top 3 language in the past 5 years, followed by SQL, the 4th popular one.</p><p>On the other hand, Go, and Rust are the less popular languages, but many developers desire to learn in the next year(2021).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*wKWv2yjN5DN_neBNgqLICw.png" /></figure><p>From the job position point of view, we can see developers with back-end skills have the highest demand, followed by full-stack and front-end developers. As a result, we can predict web service is the most popular business for now and the future. Also, desktop or enterprise applications are critical, as people still prefer using computers over mobile devices for working. However, Mobile devices are getting popular over the past years. So the mobile developer is the 5th popular job. Another trend is Automation, as DevOps specialist and DBA are the 6th and 7th popular jobs.</p><h3>Conclusion</h3><p>In this article, we took a look at what to focus on how to get a higher salary by using survey data from the Stack Overflow survey 2020. Some findings:</p><ol><li>It is worth hunting jobs from North America. Salaries are higher no matter if you are a junior developer or a senior developer, male or female.</li><li>In terms of getting the highest compensation, focus on getting a master’s degree or doctoral degree even though your salary grows with your work experience eventually. Major doesn’t play a big role.</li><li>Try to learn either Java, C, or JavaScript cause these are the top 3 languages in the past 5 years. Python and SQL are also worth learning as they got more popular as well.</li><li>Back-end, full-stack, and front-end developers are the top 3 developer types. As a result, we can predict web service is the most popular business for now and future. However, general developers, mobile developers, DevOps specialists, and DBA are also top-rated.</li></ol><p>I hope these findings will help you to pursue your dream jobs. Good luck!</p><p>To see more about this analysis, see the link to my Github available <a href="https://github.com/tinachientw/DSND_Write_a_DS_Blog">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef15822836c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Estimation Project]]></title>
            <link>https://tina-chien-tw.medium.com/estimation-project-2d4f585d1256?source=rss-ddd6e5d20164------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d4f585d1256</guid>
            <category><![CDATA[drones]]></category>
            <dc:creator><![CDATA[Tina Chien]]></dc:creator>
            <pubDate>Wed, 01 Apr 2020 13:21:36 GMT</pubDate>
            <atom:updated>2020-04-01T13:21:36.507Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>In this project, I implement a 3D estimation technique for quadrotors using Extended Kalman Filter(EKF). In the previous project, Control of a 3D Quadrotor, the drone is controlled with no noise. But the reality is we need to estimate the current position of drone, velocity, and yaw. All the maths used in the project can be found in the paper <a href="https://www.overleaf.com/project/5c34caab7ecefc04087273b9">Estimation for Quadrotors</a>.</p><p><a href="https://github.com/udacity/FCND-Estimation-CPP">Detailed Project Explanation Page from Udacity</a>.</p><h3>Setup</h3><p>This project will continue to use the C++ development environment you set up in the Controls C++ project.</p><ol><li>Clone the repository</li></ol><pre>git clone <a href="https://github.com/udacity/FCND-Estimation-CPP.git">https://github.com/udacity/FCND-Estimation-CPP.git</a></pre><p>2. Import the code into your IDE like done in the <a href="https://github.com/udacity/FCND-Controls-CPP#development-environment-setup">Controls C++ project</a></p><p>3. You should now be able to compile and run the estimation simulator just as you did in the controls project</p><h3>Project Structure</h3><p>Most of the code provided is a drone simulator. The following files where are the main files need to complete:</p><ul><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP/blob/master/src/QuadEstimatorEKF.cpp">/src/QuadEstimatorEKF.cpp</a>: The Extended Kalman Filter for state estimation is implemented in this file.</li><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP/blob/master/src/QuadControl.cpp">/src/QuadControl.cpp</a>: The cascade PID control implemented in this file. This is implemented on the previous project, Control of a 3D Quadrotor.</li><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP/blob/master/config/QuadEstimatorEKF.txt">/config/QuadEstimatorEKF.txt</a>: Parameters for tuning the EKF are in this parameter file.</li><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP/blob/master/config/QuadControlParams.txt">/config/QuadControlParams.txt</a>: Parameters for the PID control code is in QuadControlParams.txt</li></ul><h3>The Tasks</h3><p>I built up the estimator in pieces. At each step, there was a set of success criteria that were displayed both in the plots and in the terminal output.</p><p>Project outline:</p><ul><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP#step-1-sensor-noise">Step 1: Sensor Noise</a></li><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP#step-2-attitude-estimation">Step 2: Attitude Estimation</a></li><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP#step-3-prediction-step">Step 3: Prediction Step</a></li><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP#step-4-magnetometer-update">Step 4: Magnetometer Update</a></li><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP#step-5-closed-loop--gps-update">Step 5: Closed-Loop + GPS Update</a></li><li><a href="https://github.com/tinachientw/FCND-Estimation-CPP#step-6-adding-your-controller">Step 6: Adding Your Controller</a></li></ul><h3>Step 1: Sensor Noise</h3><ol><li>The first step to adding additional realism to the problem, and developing an estimator, is adding noise to the quad’s sensors. I ran scenario 06_NoisySensors collected some simulated noisy sensor data. The collected data were saved in <a href="https://github.com/tinachientw/FCND-Estimation-CPP/blob/master/src/data/Accelerometer.X.Data.txt">/src/data/Accelerometer.X.Data.txt</a> and <a href="https://github.com/tinachientw/FCND-Estimation-CPP/blob/master/src/data/GPS.X.Data.txt">/src/data/GPS.X.Data.txt</a></li><li>Then used np.std() to estimate the standard deviation of these data, it was implemented in <a href="https://github.com/tinachientw/FCND-Estimation-CPP/blob/master/src/sensor_noise.ipynb">/src/sensor_noise.ipynb</a></li></ol><pre>GPS X Std: 0.7052766300977962<br>Accelerometer X Std: 0.5096887953058913</pre><p>3. Plugin the result into the top of config/6_Sensornoise.txt. Set the values for MeasuredStdDev_GPSPosXY and MeasuredStdDev_AccelXY.</p><p>4. Run the simulator. My standard deviation correctly capturing approx 68% of the respective measurements (which is what we expect within +/- 1 sigma bound for a Gaussian noise model)</p><pre>Simulation #2 (../config/06_SensorNoise.txt)<br>PASS: ABS(Quad.GPS.X-Quad.Pos.X) was less than MeasuredStdDev_GPSPosXY for 68% of the time<br>PASS: ABS(Quad.IMU.AX-0.000000) was less than MeasuredStdDev_AccelXY for 69% of the time</pre><p>And here is a video of the scenario:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*wGs8AgJiVGSEaKoy.gif" /></figure><h3>Step 2: Attitude Estimation</h3><p>The first step to state estimation is including information from our IMU. In this step, I improved the complementary filter-type attitude filter with a better rate gyro attitude integration scheme.</p><ol><li>Run scenario 07_AttitudeEstimation. For this simulation, the only sensor used is the IMU and noise levels are set to 0 (see config/07_AttitudeEstimation.txt for all the settings for this simulation). There are two plots visible in this simulation.</li></ol><ul><li>The top graph is showing errors in each of the estimated Euler angles.</li><li>The bottom shows the true Euler angles and the estimates. Observe that there’s quite a bit of error in attitude estimation.</li></ul><p>2. In, the function UpdateFromIMU() contains a complementary filter-type attitude filter. To reduce the errors in the estimated attitude (Euler Angles), I implement a better rate gyro attitude integration scheme.</p><p>3. Turn rate in the body frame to a change in the Euler angles (world frame) is done with the matrix multiplication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*KJFRmMQWVJTb_H4h.png" /></figure><p>4. I reduced the attitude errors to get within 0.1 rad for each of the Euler angles, as shown in the screenshot below.</p><pre>Simulation #3 (../config/07_AttitudeEstimation.txt)<br>PASS: ABS(Quad.Est.E.MaxEuler) was less than 0.100000 for at least 3.000000 seconds</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*nwEqEP-YBA6Y9C-0.png" /></figure><p>In the screenshot above the attitude estimation using linear scheme (left) and using the improved nonlinear scheme (right). Note that Y axis on error is much greater on left.</p><p>And here is a video of the scenario:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*yonGtUzMB_-12ENs.gif" /></figure><h3>Step 3: Prediction Step</h3><p>Run scenario 08_PredictState. This scenario is configured to use a perfect IMU (only an IMU). Due to the sensitivity of double-integration to attitude errors, we&#39;ve made the accelerometer update very insignificant (QuadEstimatorEKF.attitudeTau = 100). The plots on this simulation show element of your estimated state and that of the true state. At the moment you should see that your estimated state does not follow the true state.</p><h3>First step: state prediction</h3><p>In QuadEstimatorEKF.cpp, I implemented the state prediction step in the PredictState() function base on the paper [Estimation for Quadrotors]((<a href="https://www.overleaf.com/read/vymfngphcccj">https://www.overleaf.com/read/vymfngphcccj</a>).</p><p>The state transition function is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wntZFaG7Hb35Jqgt.png" /></figure><p>The transition function needs the rotation matrix Rbq which rotates from the body frame to the global frame, and it is defined below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qmQWm-WAdmaNRNRs.png" /></figure><p>I used attitude.Rotate_BtoI() to convert the true acceleration from body frame to the global frame.</p><p>The estimator state tracks the actual state, with only reasonably slow drift, as shown in the figure below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*6z_zd4jSYWD3j0Pk.gif" /></figure><h3>Second Step: update the covariance matrix</h3><p>Now let’s introduce a realistic IMU, one with noise. Run scenario 09_PredictionCov. You will see a small fleet of quadcopters all using your prediction code to integrate forward. You will see two plots:</p><ol><li>The top graph shows 10 (prediction-only) position X estimates</li><li>The bottom graph shows 10 (prediction-only) velocity estimates You will notice however that the estimated covariance (white bounds) currently do not capture the growing errors.</li></ol><p>In QuadEstimatorEKF.cpp, I calculate the partial derivative of the body-to-global rotation matrix in the function GetRbgPrime() base on the equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ztMxyWSKDmUNUMhy.png" /></figure><p>Then I implemented the rest of the prediction step (predict the state covariance forward) in Predict() base on the Jacobian of g to perform a linear approximation of the system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6_7I7sJXEyb6bW4k.png" /></figure><p>There the dotted line is growing showing sigma growing over time due to the prediction step. Here is a scenario video:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*fp7dbi1YdzMFGikM.gif" /></figure><h3>Step 4: Magnetometer Update</h3><p>Up until now, we’ve only used the accelerometer and gyro for our state estimation. In this step, I added the information from the magnetometer to improve my filter’s performance in estimating the vehicle’s heading.</p><ol><li>Run scenario 10_MagUpdate. This scenario uses a realistic IMU, but the magnetometer update hasn’t been implemented yet. As a result, you will notice that the estimated yaw is drifting away from the real value (and the estimated standard deviation is also increasing). Note that in this case, the plot is showing you the estimated yaw error (quad.est.e.yaw), which is drifting away from zero as the simulation runs. You should also see the estimated standard deviation of that state (white boundary) is also increasing.</li><li>I Tune the parameter QYawStd to 0.08 (QuadEstimatorEKF.txt) for the QuadEstimatorEKF so that it approximately captures the magnitude of the drift, as demonstrated here:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/308/0*ooIX8rkljVy5UHiO.png" /></figure><p>3. Then I implemented magnetometer update in the function UpdateFromMag() base on the paper <a href="https://www.overleaf.com/project/5c34caab7ecefc04087273b9">Estimation for Quadrotors</a>, 7.3.2 Magnetometer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QItp5FoyhIMpDcwR.png" /></figure><p>You can see there the yaw error decrease, and the sigma remained stable. Here is a scenario video:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*gNPLAMqmrRUCGaQ4.gif" /></figure><p>I successfully obtained an estimated standard deviation that accurately captures the error and maintains an error of less than 0.1rad in heading for at least 10 seconds of the simulation.</p><pre>Simulation #3 (../config/10_MagUpdate.txt)<br>PASS: ABS(Quad.Est.E.Yaw) was less than 0.120000 for at least 10.000000 seconds<br>PASS: ABS(Quad.Est.E.Yaw-0.000000) was less than Quad.Est.S.Yaw for 66% of the time</pre><h3>Step 5: Closed-Loop + GPS Update</h3><p>Before implementing the GPS update step the position and velocity errors (bottom right) drift away.</p><ol><li>Run scenario 11_GPSUpdate. At the moment this scenario is using both an ideal estimator and ideal IMU. Even with these ideal elements, watch the position and velocity errors (bottom right). As you see they are drifting away since GPS update is not yet implemented.</li><li>And after we change to using our estimator by setting Quad.UseIdealEstimator to 0 in config/11_GPSUpdate.txt the drone goes wild from time to time as well:</li><li>I implemented the EKF GPS Update in the function UpdateFromGPS() base on the paper section 7.3.1 of <a href="https://www.overleaf.com/read/vymfngphcccj">Estimation for Quadrotors</a> for a refresher on the GPS update.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bX_YKoV1hDcYDcPr.png" /></figure><p>I successfully completed the entire simulation cycle with estimated position error of &lt; 1m.*</p><pre>Simulation #3 (../config/11_GPSUpdate.txt) PASS: ABS(Quad.Est.E.Pos) was less than 1.000000 for at least 20.000000 seconds</pre><p>Here is a scenario video:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*tK7DkWMlHjl4_99k.gif" /></figure><h3>Step 6: Adding Your Controller</h3><p>to know how well my controller performs and de-tune your controller accordingly.</p><ol><li>I replaced QuadController.cpp with the controller, I wrote in the last project.</li><li>I replaced QuadControlParams.txt with the control parameters I came up with the last project.</li><li>Run scenario 11_GPSUpdate again.</li></ol><p>I was lucky to successfully completed the entire simulation cycle with an estimated position error of &lt; 1m.* without tuning the control parameters.</p><pre>Simulation #3 (../config/11_GPSUpdate.txt)<br>PASS: ABS(Quad.Est.E.Pos) was less than 1.000000 for at least 20.000000 seconds</pre><p>Here is a scenario video:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*k6BlNztdMmkmgJbr.gif" /></figure><h3>Authors</h3><p>Thanks to Fotokite for the initial development of the project code and simulator.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d4f585d1256" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3D Motion Planning]]></title>
            <link>https://tina-chien-tw.medium.com/3d-motion-planning-6d3956d41159?source=rss-ddd6e5d20164------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d3956d41159</guid>
            <dc:creator><![CDATA[Tina Chien]]></dc:creator>
            <pubDate>Tue, 03 Mar 2020 22:34:36 GMT</pubDate>
            <atom:updated>2020-03-14T09:37:20.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lQnI-gfwOlhgzphI.png" /></figure><h3>Overview</h3><p>This project demonstrates how the drone flies from the start to goal location through the 2.5D map. Discretize the environment into a grid &amp; graph representation. Use A* search algorithm to find the shortest path. More detail information about the simulator and python environment setup can be found <a href="https://github.com/hayaalsh/FCND-Motion-Planning/blob/master/README_Udacity.md">here</a>.</p><p>All the code of implementation can be found <a href="https://github.com/tinachientw/FCND-Motion-Planning">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*ySre4Eve4LjCFo1Ambj1Cw.png" /></figure><h3>Load 2.5D map</h3><p>Due to my computer is not fast enough to finish the path planning within the simulator connection timeout. So I have to preload the map and finish the path planning before connecting to the simulator. I designed a class call MapData to do so.</p><p>All the map data will be load while MapData initializes. A grid for a particular altitude and safety margin around obstacles will also be built. To create the grid using create_grid() in grid_search.py</p><pre># read lat0, lon0 from colliders into floating point values<br> header = open(map_file_name).readline()<br> s = re.findall(r&quot;[-+]?\d*\.\d+|\d+&quot;, header)<br> self.lat_0 = float(s[1]) #global hoome position of drone<br> self.lon_0 = float(s[3])</pre><pre># Read in obstacle map<br> data = np.loadtxt(map_file_name, delimiter=&#39;,&#39;, dtype=&#39;Float64&#39;, skiprows=2)<br>        <br> # Define a grid for a particular altitude and safety margin around obstacles<br> self.grid, self.north_offset, self.east_offset = create_grid(data, self.TARGET_ALTITUDE, self.SAFETY_DISTANCE)</pre><p>The home position will be set while the drone arming. To set the global home position using self.set_home_position().</p><pre>def arming_transition(self):<br>        self.flight_state = States.ARMING<br>        print(&quot;&lt;arming transition&gt;&quot;)<br>        self.arm()<br>        self.take_control()<br>        self.set_home_position(self.lon_0, self.lat_0, 0)<br>        print(f&#39;Home lat : {self.lat_0}, lon : {self.lon_0}&#39;)</pre><h3>Path Planning</h3><h3>Grid-Based Implementation</h3><p>In motion_planning_grid_map.py , you can choose the start and goal location. But the start location should be close to the home location of drone. So the drone will fly through the path.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/0*5T59UVdmkq3HCvBk.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FtxL9tiy-9wo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DtxL9tiy-9wo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FtxL9tiy-9wo%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/063fe754de378e96101e9062c608901c/href">https://medium.com/media/063fe754de378e96101e9062c608901c/href</a></iframe><h3>A* search with diagonal motion</h3><p>In grid_search.py , the a_stat() calculate the shortest path and check if the note is valid or not by using valid_actions(grid, current_node). The action() enum class defines the actions. So the following code was added for diagonal motion accordingly.</p><pre>if x + 1 &gt; n or y + 1 &gt; m or grid[x + 1, y + 1] == 1:<br>        valid_actions.remove(Action.SOUTH_EAST)<br>    if x - 1 &lt; 0 or y + 1 &gt; m or grid[x - 1, y + 1] == 1:<br>        valid_actions.remove(Action.NORTH_EAST)<br>    if x + 1 &gt; n or y - 1 &lt; 0 or grid[x + 1, y - 1] == 1:<br>        valid_actions.remove(Action.SOUTH_WEST)<br>    if x - 1 &lt; 0 or y - 1 &lt; 0 or grid[x - 1, y - 1] == 1:<br>        valid_actions.remove(Action.NORTH_WEST)</pre><p>The cost of diagonal motions is sqrt(2)</p><pre>SOUTH_EAST = (1, 1, np.sqrt(2))<br>    NORTH_EAST = (-1, 1, np.sqrt(2))<br>    SOUTH_WEST = (1, -1, np.sqrt(2))<br>    NORTH_WEST = (-1, -1, np.sqrt(2))</pre><h3>Remove unnecessary waypoints</h3><p>After path planing, run collinearity test to remove unnecessary waypoints by calling prune_path().</p><pre>def prune_path(path, epsilon=1e-5):<br>    &quot;&quot;&quot;<br>    Returns prune path.<br>    &quot;&quot;&quot;<br>    def point(p):<br>        return np.array([p[0], p[1], 1.]).reshape(1, -1)</pre><pre>def collinearity_check(p1, p2, p3):   <br>        m = np.concatenate((p1, p2, p3), 0)<br>        det = np.linalg.det(m)<br>        return abs(det) &lt; epsilon</pre><pre>pruned_path = [p for p in path]<br>    i = 0<br>    while i &lt; len(pruned_path) - 2:<br>        p1 = point(pruned_path[i])<br>        p2 = point(pruned_path[i+1])<br>        p3 = point(pruned_path[i+2])</pre><pre>if collinearity_check(p1, p2, p3):<br>            pruned_path.remove(pruned_path[i+1])<br>        else:<br>            i += 1<br>    return pruned_path</pre><h3>Graph-Based Implementation</h3><p>In motion_planning_graph_map.py , you choose the start and goal location. A graph with edges is created by using create_graph_and_edges() in graph_search.py. The closet notes will be found according to the locations, then use the a_star() to calculate the shortest path according to the graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/0*Vhomqn4836BEd8A7.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F8HhC1Rl7rmI%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D8HhC1Rl7rmI&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F8HhC1Rl7rmI%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/b7783e72dfc6d796c17aaba1dc597f46/href">https://medium.com/media/b7783e72dfc6d796c17aaba1dc597f46/href</a></iframe><h3>Probabilistic Roadmap Algorithm</h3><p>In motion_planning_probabilistic_roadmap.py, you choose the start and goal location. A graph with random notes is created by using create_graph_with_nodes() in probabilistic_roadmap.py. While creating the graph, I used the KD Tree data structure to quickly identify nearest neighbors to a point or polygon. The total search time down to O(m * log(n)) from O(m*n), where m is the number of elements to compare to and n is the number of elements in the KD Tree.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/0*JHOYtHhzEHEFMB-q.png" /></figure><p>The notes which collide with obstacles will be discarded by using can_connect().</p><pre>def can_connect(n1, n2):<br>    l = LineString([n1, n2])</pre><pre>global polygons<br>    for p in polygons:<br>        if p.crosses(l) and p.height &gt;= min(n1[2], n2[2]):<br>            return False<br>    return True</pre><p>Then use the a_star() to calculate the shortest path according to the graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/0*DT9dadwJwzIW-P-t.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FDPHO8Zf3YFg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DDPHO8Zf3YFg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FDPHO8Zf3YFg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/93503e93b9641eb7f88eab52e2a7e34e/href">https://medium.com/media/93503e93b9641eb7f88eab52e2a7e34e/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d3956d41159" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extended Kalman Filter]]></title>
            <link>https://tina-chien-tw.medium.com/extended-kalman-filter-cdfff2b2ce2e?source=rss-ddd6e5d20164------2</link>
            <guid isPermaLink="false">https://medium.com/p/cdfff2b2ce2e</guid>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Tina Chien]]></dc:creator>
            <pubDate>Mon, 17 Jun 2019 10:24:19 GMT</pubDate>
            <atom:updated>2019-06-17T10:26:30.167Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>In this project I utilize a kalman filter to estimate the state of a moving object of interest with noisy lidar and radar measurements. Passing the project requires obtaining RMSE values that are lower than the tolerance outlined in the project rubric.</p><p>This project involves the Term 2 Simulator which can be downloaded <a href="https://github.com/udacity/self-driving-car-sim/releases">here</a>.</p><p>This repository includes two files that can be used to set up and install <a href="https://github.com/uWebSockets/uWebSockets">uWebSocketIO</a> for either Linux or Mac systems. For windows you can use either Docker, VMware, or even <a href="https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/">Windows 10 Bash on Ubuntu</a> to install uWebSocketIO. Please see the uWebSocketIO Starter Guide page in the classroom within the EKF Project lesson for the required version and installation scripts.</p><p>Once the install for uWebSocketIO is complete, the main program can be built and run by doing the following from the project top directory.</p><ol><li>mkdir build</li><li>cd build</li><li>cmake ..</li><li>make</li><li>./ExtendedKF</li></ol><p>All these files can be found in my project [<a href="https://github.com/tinachientw/CarND-Extended-Kalman-Filter-Project">repository on GitHub</a>]</p><h3>Program Flow:</h3><p>This program follows the flow of this chart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Rb5ItLboObztU1R1.PNG" /></figure><h3>Kalman Filter Algorithm</h3><p>Prediction:</p><blockquote>x′ =Fx+u (11)</blockquote><blockquote>P′=FPFT+Q</blockquote><p>Measurement Update:</p><blockquote>x′ =Fx+u (11) P′=FPFT+Q</blockquote><blockquote>y = z − Hx′ (13) S=HP′HT+R (14) K = P′HT S−1</blockquote><blockquote>x = x′ + Ky (16) P=(I−KH)P′</blockquote><p>The measurement function can be found in kalman_filter.cpp and the CalculateJacobian() in tools.cpp.</p><h3>State Update with Kalman Filter equation or Extended Kalman Filter equation:</h3><h4>Radar:</h4><p>1.Linearize measurement function by calculating jacobian matrix Hj:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/0*2S0NTWFX9JaFkPw3.PNG" /></figure><p>2.Run measurement update with Extended Kalman Filter equations:</p><p>3.Image referenced is of Kalman Filter equations. Extended Kalman Filter equation is modified to be y = z — h(x), and uses Hj in place of any other H. h(x) is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/0*ZXfeuR63k1iJsoF2.PNG" /></figure><h4>Lidar:</h4><p>1.Update function run from standard Kalman Filter equations</p><h3>Extended Kalman Filter</h3><p>In the screenshots below, the green triangles represent the predicted location, the red circles are from the laser sensor, and the blue markers are from the radar sensor. We measure the accuracy of the algorithm by calculating the RMSE of the x, y positions and the velocity along the x, y axis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/633/1*g1b9BNT9GasmqVA0fz9weA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*oHY2SOx9HgAaXpXvAvfRGQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cdfff2b2ce2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Behavioral Cloning Project]]></title>
            <link>https://tina-chien-tw.medium.com/behavioral-cloning-project-3fadf2ae0db2?source=rss-ddd6e5d20164------2</link>
            <guid isPermaLink="false">https://medium.com/p/3fadf2ae0db2</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Tina Chien]]></dc:creator>
            <pubDate>Mon, 17 Jun 2019 09:37:10 GMT</pubDate>
            <atom:updated>2019-06-20T01:40:25.652Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>In this project, I design, train, and test a convolutional neural network (CNN) to clone the driving behavior from sample images recorded from <a href="https://github.com/udacity/self-driving-car-sim">Udacity’s driving simulator</a>.</p><p>The goals / steps of this project are the following: Use the simulator to collect data of good driving behavior Build, a convolution neural network (using Keras) that predicts steering angles from images Train and validate the model with a training and validation set Test that the model successfully drives around the track without leaving the road</p><h3>Submission Files</h3><p>My project submission includes the following files:</p><ul><li>model.py – the script used to create and train the final model.</li><li>model.ipynb - the notebook used for development</li><li>drive.py – the script provided by Udacity that is used to drive the car. I did not modify this script in any way.</li><li>model.h5 – the saved model file. It can be used with Keras to load and compile the model.</li><li>report.pdf – written report, that you are reading right now. It describes all the important steps done to complete the project.</li><li>video.mp4 – video of the car, driving autonomously on the basic track.</li></ul><p>All these files can be found in my project <a href="https://github.com/tinachientw/CarND-Behavioral-Cloning-P3">[repository on GitHub]</a></p><h3>Installation &amp; Resources</h3><ul><li>Anaconda Python 3.7</li><li>Udacity <a href="https://github.com/udacity/CarND-Term1-Starter-Kit">Carnd-term1 starter kit</a> with miniconda installation</li><li>Udacity <a href="https://github.com/udacity/self-driving-car-sim">Car Simulation</a> on MacOC</li><li>Udacity <a href="https://d17h27t6h515a5.cloudfront.net/topher/2016/December/584f6edd_data/data.zip">sample data</a></li></ul><h3>Quickstart</h3><ul><li>Two driving modes:</li></ul><p>Training: For user to take control over the car Autonomous: For car to drive by itself</p><ul><li>Collecting data: User drives on track 1 and collects data by recording the driving experience by toggle ON/OFF the recorder. Data is saved as frame images and a driving log which shows the location of the images, steering angle, throttle, speed, etc. Another option is trying on Udacity data sample.</li></ul><h3>Approach</h3><p>To have any idea to start this project, the CNN that was eventually used was based on <a href="https://arxiv.org/pdf/1604.07316v1.pdf">NVIDIA’s End to End Learning for Self-Driving Cars</a> paper with different input image size and with dropout added to improve robustness. From the paper, data collection is the first important part. Per project requirement, data collection can only performed on Track 1. I drove about 4 laps around Track 1 by keyboard control to collect data. The driving wasn’t extrememly smooth as actual driving. So I decided to use Udacity sample data as starting point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/0*Oo_41TLl3fBrua49.png" /></figure><h3>Understanding Data</h3><p>There are 3 cameras on the car which shows left, center and right images for each steering angle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/0*Ay6wc3iThsZgav1S.png" /></figure><p>views_plot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*vIcbNdG6G2Qkaru8.png" /></figure><p>After recording and save data, the simulator saves all the frame images in IMG folder and produces a driving_log.csv file which containts all the information needed for data preparation such as path to images folder, steering angle at each frame, throttle, brake and speed values.</p><p>driving_log</p><p>In this project, we only need to predict steering angle. So we will ignore throttle, brake and speed information.</p><h3>Model Architecture</h3><p>The model has:</p><ol><li>Two preprocessing layers, which I will describe later when talking about data.</li><li>Three convolutional layers with (5,5) kernels (24, 26 and 48 kernels per layer, correspondingly) with (2,2) strides, followed by</li><li>Two convolutional layers with (3,3) kernels (64 kernels per layer) with (1,1) strides, followed by</li><li>Three fully connected layers (with 100, 50 and 10 neurons, correspondingly), followed by</li><li>Output layer with one output neuron that controls the steering wheel.</li></ol><p>I decided to use ELU (Exponential Linear Unit) activation, because <a href="http://image-net.org/challenges/posters/JKU_EN_RGB_Schwarz_poster.pdf">there is evidence</a> that it can be slightly better than RELU.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/0*pwfJmFxZZSkzhzkB.png" /></figure><h3>Training and Validation</h3><p>In order to train a model, I used two generators — one for training and one for validation. Validation data generator was used to assess out-of-sample performance. Training generator was performing random data augmentation to improve generalization capabilities of the model, but validation generator was only performing preprocessing without doing any of the augmentation.</p><p>When training the model as described in NVIDIA paper, I noticed that training error quickly was becoming smaller than validation error, which is the sign of overfitting. To reduce that I introduced dropout layers after each convolutional and each dense layer with the exception of the output layer. After training the model with different values of dropout I stopped at 0.5 for the final model.</p><h3>Data Preprocessing</h3><p>The secret sauce in making the car drive itself well is not so much the architecture, but the data.</p><p>To achieve a more uniform distribution. I tried augment the data, also reduce the occurrence of low and zero angle data points, But the training time was too long and the car didn’t drive smoothly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*xPsouDx6nxCLN6J0.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*NC5zdQQEE6lz5rqT.png" /></figure><p>So I didn’t augment the data, but remove the data to make it more uniform distributed. Again, the car didn’t drive very well due to I dropped off too many data. (Here’s the original distribution of the training data (the x-axis corresponds to steering angles and the y-axis is the data point count for that angle range; Blue bars represent overrepresented classes, removed during data preprocessing step.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/0*wl13tJ5Pbf_V1zpn.png" /></figure><p>After several try and error, I got a better result by not making the distribution uniformed overall, but make sure it’s much closer to uniform for lower and zero turning angles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*l5tuTc741Lkxdc0o.png" /></figure><h3>Test Drive</h3><p>Track 1: Click on the image to watch the video or click <a href="https://youtu.be/ULiEcbUM2io">here</a>. You will be redirected to YouTube.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FULiEcbUM2io%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DULiEcbUM2io&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FULiEcbUM2io%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/61aa733bbdf0f8df7ed6e5a453456687/href">https://medium.com/media/61aa733bbdf0f8df7ed6e5a453456687/href</a></iframe><h3>Challenges with the Project</h3><ul><li>Data: I am not good at playing video games, also my driving skill is very bad. Therefore, it’s imposible for me to get the good data from simulator. It was the most difficult challenge for me, getting a smooth driving data. Fortunately, Udacity provides the sample data. Or I will never able to finish the project.</li><li>Training time: I used my local Linux server to train my model, but my GPU was not fast enough. So I could only train the model once or twice per day, which is very frustrated. So I tried Numba, a High Performance Python Compiler, to speed it up and tried not augment the data to reduce the training time.</li><li>Data preprocessing: Only very simple data preprocessing steps were taken. It might be beneficial to combine some of the steps that were implemented in the other projects to help, for example, highlight the lane lines more clearly so that the model can use less noisy input data.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3fadf2ae0db2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Traffic Sign Recognition Program]]></title>
            <link>https://tina-chien-tw.medium.com/build-a-traffic-sign-recognition-program-20d0482c2c24?source=rss-ddd6e5d20164------2</link>
            <guid isPermaLink="false">https://medium.com/p/20d0482c2c24</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[self-driving-cars]]></category>
            <dc:creator><![CDATA[Tina Chien]]></dc:creator>
            <pubDate>Mon, 17 Jun 2019 09:32:53 GMT</pubDate>
            <atom:updated>2019-06-17T09:34:45.284Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>In this project, I used what I’ve learned about deep neural networks and convolutional neural networks to classify traffic signs. I trained and validated a model so it can classify traffic sign images using the <a href="http://benchmark.ini.rub.de/?section=gtsrb&amp;subsection=dataset">German Traffic Sign Dataset</a>. After the model is trained, I try out my model on images of German traffic signs that I find on the web.</p><p>The steps of this project are listed below. You can have a look at <a href="https://github.com/tinachientw/CarND-Traffic-Sign-Classifier-Project/blob/master/Traffic_Sign_Classifier.ipynb">Traffic_Sign_Classifier.ipynb</a> for the code. Find a more in-depth discussion at my [<a href="https://github.com/tinachientw/CarND-Traffic-Sign-Classifier-Project">GitHub</a>]</p><p>To meet specifications, the project will require submitting three files:</p><ul><li>the Ipython notebook with the code</li><li>the code exported as an html file</li><li>a writeup report either as a markdown or pdf file</li></ul><h3>The Project</h3><p>The goals / steps of this project are the following:</p><ul><li>Load the data set</li><li>Explore, summarize and visualize the data set</li><li>Design, train and test a model architecture</li><li>Use the model to make predictions on new images</li><li>Analyze the softmax probabilities of the new images</li><li>Summarize the results with a written report</li></ul><h3>Dependencies</h3><p>This project requires Python 3.5 and the following Python libraries installed:</p><ul><li>Jupyter</li><li>NumPy</li><li>TensorFlow</li><li>Matplotlib</li><li>Numba</li><li>OvenCV</li><li>Pandas (Optional)</li></ul><p>Run this command at the terminal prompt to install OpenCV. Useful for image processing:</p><pre>conda install -c https://conda.anaconda.org/menpo opencv3</pre><h3>Data Set Summary &amp; Exploration</h3><p>Download the <a href="https://s3-us-west-1.amazonaws.com/udacity-selfdrivingcar/traffic-signs-data.zip">dataset</a>. This is a pickled dataset in which we’ve already resized the images to 32x32.</p><p>1. Basic summary of the data set. In order to calculate summary statistics for the data set, I used numpy library. The results are as follows:</p><ul><li>The size of training set is 34799 images.</li><li>The size of the validation set is 4410 images.</li><li>The size of test set is 12630 images.</li><li>The shape of a traffic sign image is 32x32x3. This means that each picture is 32 pixels wide, 32 pixels tall, and has 3 color channels.</li><li>The number of unique classes/labels in the data set is 43.</li></ul><p>2. Exploratory visualization of the dataset.</p><p>I plot some traffic signs randomly. As you can see from the images below, the lighting conditions under which the phtos were taken vary drastically. Some of the photos are hard to tell apart because the lighting was too dark. This can be a big challenge to train the network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/0*SOrOypYkbPsccDOE.png" /></figure><p>Also the number of training examples for each class varies. The histogram showing the number of training examples for each class. The imbalance data set is another thing need to be fixed. In order to solve this issue, I balanced the classes in such a way that all of them have equal number of images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/0*BvAZiU0141Xh50IW.png" /></figure><h3>Design and Test a Model Architecture</h3><p>1. Image preprocessing.</p><ul><li>Normalization: Normalizing all pictures by substracting mean value and dividing by the standard deviation of the mean value. This normalization was performed for each of 3 of the color channels. (This approach was inspired by the <a href="https://arxiv.org/pdf/1409.1556.pdf">VGG19</a> paper) An important consideration was data leakage, so the mean and SD values used for all normalization were calculated only based on the training data set, and not validation or test data.</li><li>Augmentation: To make class balance, I used CV2 package to rotation, translation and shear to generate new images. Resulting transformed images can be seen below.</li><li>Converting to grayscale for ConvNet This worked well for ConvNet as described in their traffic sign classification article. It also helps to reduce training time, which was nice when a GPU wasn’t fast enough.</li></ul><p>After augmentation/balancing, each class has 2010 images, which is how many images the largest class had before augmentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/719/0*JSUm_RyVwxgtEr6I.png" /></figure><p>2. Model architecture. The first model I used is LeNet-5 Model</p><p>LeNet-5 Model Architecture</p><p><a href="http://yann.lecun.com/exdb/publis/pdf/sermanet-ijcnn-11.pdf">LeNet-5 [1998, paper by LeCun et al.]</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aifrSKRFV7k78r4P.png" /></figure><p>As described in VGG19, the network learn the best color channel combination by having 3 1X1 convolution chanels in first layer. The original RGB color scheme sometimes is not the best for deep learing. We can make a network learn from itself, this can also improve accuracy.</p><p>About max pooling layers, the first convolutional layer (1x1 doesn’t count) doesn’t have max pooling, whereas the other two do have 2x2 max pooling. You may ask why, and the answer has to do with dimesionality reduction. Had I used max pooling after first layer, the output from which has 30x30 spacial dimansion, and after max pooling that would be 15x15, which after next convolutional layer would be 13x13, at which point 2x2 max pooling cannot be applied. This means I needed to plan convolutional and max pooling layers in such a fashion that all corresponding input-output spacial dimensions are even number of pixels.</p><p>After training the model, the results of LeNet-5 were:</p><ul><li>training set accuracy of 0.959</li><li>validation set accuracy of 0.947</li><li>test set accuracy of 0.917</li></ul><p>The accuracy wasn’t as high as I expected and the training time is too lang due to my GPU wasn’t fast enough. So I try the ConvNet model for better result and less training time.</p><p>ConvNet Model Architecture</p><p><a href="http://yann.lecun.com/exdb/publis/pdf/sermanet-ijcnn-11.pdf">ConvNet [traffic sign classification journal article 2011, paper by Sermanet/LeCunn.]</a></p><p>I implemented the ConvNet model from their traffic sign classifier paper and saw an immediate improvement. Although the paper doesn’t go into detail describing exactly how the model is implemented (particularly the depth of the layers) But it works. The layers are set up like this:</p><p>LayersDescription5x5 convolution32x32x1 in, 28x28x6 outReLU2x2 max pool28x28x6 in, 14x14x6 out5x5 convolution14x14x6 in, 10x10x16 outReLU2x2 max pool10x10x16 in, 5x5x16 out5x5 convolution5x5x6 in, 1x1x400 outReLuFlatten layersfrom numbers 8 (1x1x400 -&gt; 400) and 6 (5x5x16 -&gt; 400)Concatenateflattened layers to a single size-800 layerDropout layerFully connected layer800 in, 43 out</p><p>3. Training the model.</p><p>To train the model, I made the following decisions:</p><ul><li>Adam optimizer. Adam optimizer uses adaptive decrease of the learning rate. It is quite useful, as it allows the optimizing algorithm to slow down as it approaches solution.</li><li>Starting learning rate of 0.0009. This choice was motivated by trial and error and also by looking at what practitioners use for this type of optimizer.</li><li>Batch size of 32. My memory wasn’t big enough. I was getting out of memory errors when trying to make this value larger, so I decided to stop at 32.</li><li>Number of epochs was 201. Since one epoch trained relatively fast (12 seconds on average), I could afford to run it for longer and see if it converges to some value (which it did).</li><li>Use Numba, a JIT compiler, to make Python code fast.</li></ul><p>4. Finding the final solution.</p><p>In the graph below, the blue line represents training accuracy and the orange line represents validation accuracy. In the beginning of the training, validation accuracy is higher than training accuracy. This is the result of using dropout. This reduces training accuracy and prevents overfitting. Using dropout additionally reduces the gap between training and validation accuracy, which is good. On the downside, training requires more epochs to converge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/0*blREYkFck9h8jE6_.png" /></figure><p>After training the model for 201 epochs, the final results were:</p><ul><li>training set accuracy of 0.999</li><li>validation set accuracy of 0.974</li><li>test set accuracy of 0.946</li></ul><p>During this project, I have tried some architectures and encountered numerous challenges. Unfortunately, I did not keep a log of all approaches that I tried.</p><p>In the begining, I tried the LeNet architecture. I chose it because, both MNIST digits data set and traffic signs are similar in complexity. Both have simple fatures that distinguish classes. But the accuracy is not as high as I expected and the runing time is long due to my GPU is not fast enough.</p><p>Then I tried the ConvNet architecture which is also LeCun’s model. The main reason is the images were grayscale. This worked well for Sermanet and LeCun as described in their traffic sign classification article. It also helps to reduce training time, which was nice when my GPU was slow. The classes of Tensorflow and LeNet labs help a lot when I have to use rial and error approach. Beside this, the Deep Learing course of Andrew Ng helped me to tune the hyperparameters to get a good level of validation accuracy.</p><h3>Test a Model on New Images</h3><p>1. New German traffic signs.</p><p>Here are 12 German traffic signs that I found on the web:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/0*35kPmABgLD3DW91T.png" /></figure><p>2. Model’s predictions on the new traffic signs.</p><p>All the photos should be distinguished easily, cause none of them were taken in low light conditions. And the result is as good as I expected, with 100% accuracy. This is a good sign as the model performs well on real-world data. But we can assume that the accuracy could not remain so high by given more data points if the image isn’t as bright as the new images.</p><p>3. Softmax probabilities for all new signs.</p><p>Results can be seen in the figure below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/0*ukK8T_Pw6QIMaKY0.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/0*rNk8dzphOvMI4FcG.png" /></figure><p>4 (Optional): Visualize the Neural Network’s State with Test Images</p><p>-Featuremap for Pooling layer which is having output shape of 14x14x6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XIdr9CK26b099y4X.png" /></figure><p>-Featuremap for Pooling layer which is having output shape of 5x5x16.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rc307gO5VYYlaq7m.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20d0482c2c24" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Lane Finding]]></title>
            <link>https://tina-chien-tw.medium.com/advanced-lane-finding-faa3084492eb?source=rss-ddd6e5d20164------2</link>
            <guid isPermaLink="false">https://medium.com/p/faa3084492eb</guid>
            <category><![CDATA[self-driving-cars]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Tina Chien]]></dc:creator>
            <pubDate>Mon, 17 Jun 2019 08:37:44 GMT</pubDate>
            <atom:updated>2019-06-20T01:38:54.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vO0kRQHbrocbRDbt.jpg" /></figure><h3>Overview</h3><p>In this project, I will write a software pipeline to identify the lane boundaries in a video from a front-facing camera on a car. The camera calibration images, test road images, and project videos are available in the project repository.</p><p>The steps of this project are listed below. You can have a look at <a href="https://github.com/tinachientw/CarND-Advanced-Lane-Lines/blob/master/advanced_land_finding.ipynb">Advanced_Lane_Lines.ipynb</a> for the code. Find a more in-depth discussion at my [<a href="https://github.com/tinachientw/CarND-Advanced-Lane-Lines">GitHub</a>]</p><h3>The Project</h3><p>The goals / steps of this project are the following:</p><ul><li>Compute the camera calibration matrix and distortion coefficients given a set of chessboard images.</li><li>Apply a distortion correction to raw images.</li><li>Use color transforms, gradients, etc., to create a thresholded binary image.</li><li>Apply a perspective transform to rectify binary image (“birds-eye view”).</li><li>Detect lane pixels and fit to find the lane boundary.</li><li>Determine the curvature of the lane and vehicle position with respect to center.</li><li>Warp the detected lane boundaries back onto the original image.</li><li>Output visual display of the lane boundaries and numerical estimation of lane curvature and vehicle position.</li></ul><h3>Initialization: Import and initialize the packages needed in the projects</h3><ul><li>OpenCV — an open source computer vision library,</li><li>Matplotbib — a python 2D plotting libray,</li><li>Numpy — a package for scientific computing with Python,</li><li>MoviePy — a Python module for video editing.</li></ul><h3>Step 1: Compute the camera calibration using chessboard images</h3><p>The next step is to perform a camera calibration. A set of chessboard images will be used for this purpose.</p><p>The camera_calibration() function takes as input parameters an array of paths to chessboards images, and the number of inside corners in the x and y axis.</p><p>For each image path, calibrate camera:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*25mPsCM2vGqwDnmb.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*7b0J7OuhVlnH87LQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*hjt3y2qjkemEdhW9.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/0*7JTeKL1kg22DeAOP.png" /></figure><p>reads the image by using the OpenCV cv2.imread function, converts it to grayscale usign cv2.cvtColor, find the chessboard corners usign cv2.findChessboardCorners Finally, the function uses all the chessboard corners to calibrate the camera by invoking cv2.calibrateCamera.</p><p>The values returned by cv2.calibrateCamera will be used later to undistort our video images.</p><h3>Step 2: Apply a distortion correction to raw images</h3><p>Another OpenCv funtion, cv2.undistort, will be used to undistort images.</p><p>Below, it can be observed the result of undistorting one of the chessboard images:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oL4dlg7LkZLLa7lg.png" /></figure><h3>Step 3: Use color transforms, gradients, etc., to create a thresholded binary image.</h3><p>Different color space configurations of challenging frames</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/839/0*f6x4Tn7_PxucfRp_.png" /></figure><p>As we can see the lanes lines in the challenge and harder challenge videos were extremely difficult to detect. They were either too bright or too dull. So the get_thresholded_image() functionThis use R &amp; G channel thresholding and L channel thresholding</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6yj4quQLPGp5Gfg5.png" /></figure><p>An in-depth explanation about how these functions work can be found at the <a href="https://classroom.udacity.com/nanodegrees/nd013/parts/fbf77062-5703-404e-b60c-95b78b2f3f9e/modules/2b62a1c3-e151-4a0e-b6b6-e424fa46ceab/lessons/096009a1-3d76-4290-92f3-055961019d5e/concepts/016c6236-7f8c-4c07-8232-a3d099c5454a">Lesson 15: Advanced Techniques for Lane Finding of Udacity’s Self Driving Car Engineer Nanodegree</a>.</p><h3>Step 4: Apply a perspective transform to rectify binary image (“birds-eye view”).</h3><p>After manually examining a sample image, I extracted the vertices to perform a perspective transform. The polygon with these vertices is drawn on the image for visualization. Destination points are chosen such that straight lanes appear more or less parallel in the transformed image. Opencv function cv2.getPerspectiveTransform will be used to calculate both, the perpective transform M and the inverse perpective transform Minv. M and Minv will be used respectively to warp and unwarp the video images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fx4eBHjl8RvmcEhw.png" /></figure><h3>Step 5: Detect lane pixels and fit to find the lane boundary.</h3><ul><li>Use histogram of the lower half of the warped image.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/0*eN4S9o7BByaNK-dt.png" /></figure><ul><li>Then, the starting left and right lanes positions are selected by looking to the max value of the histogram to the left and the right of the histogram’s mid position.</li><li>A technique known as Sliding Window is used to identify the most likely coordinates of the lane lines in a window, which slides vertically through the image for both the left and right line.</li><li>Finally, usign the coordinates previously calculated, a second order polynomial is calculated for both the left and right lane line. Numpy’s function np.polyfit will be used to calculate the polynomials. Please find below the result of applying the detect_lines() function to the warped image:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BaJf3fa0tkJxdhDs.png" /></figure><p>Once you have selected the lines, it is reasonable to assume that the lines will remain there in future video frames. detect_similar_lines() uses the previosly calculated line_fits to try to identify the lane lines in a consecutive image. If it fails to calculate it, it invokes detect_lines() function to perform a full search.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R6csgeFc2Uf8Zxqg.png" /></figure><h3>Step 6: Determine the curvature of the lane and vehicle position with respect to center.</h3><p>The radius of curvature is computed according to the formula and method described in the classroom material. Since we perform the polynomial fit in pixels and whereas the curvature has to be calculated in real world meters, we have to use a pixel to meter transformation and recompute the fit again.</p><p>The mean of the lane pixels closest to the car gives us the center of the lane. The center of the image gives us the position of the car. The difference between the 2 is the offset from the center.</p><p>For further information, please refer to <a href="https://classroom.udacity.com/nanodegrees/nd013/parts/fbf77062-5703-404e-b60c-95b78b2f3f9e/modules/2b62a1c3-e151-4a0e-b6b6-e424fa46ceab/lessons/096009a1-3d76-4290-92f3-055961019d5e/concepts/016c6236-7f8c-4c07-8232-a3d099c5454a">Lesson 15: Advanced Techniques for Lane Finding of Udacity’s Self Driving Car Engineer Nanodegree</a>.</p><h3>Step 7. Warp the detected lane boundaries back onto the original image.</h3><p>Inverse Transform : Paint the lane area Perform an inverse perspective transform Combine the precessed image with the original image. nwarp.png</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VX6H-yr4cQ16WY_d.png" /></figure><h3>Step 8. Output visual display of the lane boundaries and numerical estimation of lane curvature and vehicle position.</h3><p>We apply the pipeline to a test image. This is the final result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1MsSIE4v_yN8bp8s.png" /></figure><h3>The Video</h3><p>The pipeline is applied to a video. Click on the image to watch the video or click <a href="https://youtu.be/RIZyNokDw9o">here</a>. You will be redirected to YouTube.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FRIZyNokDw9o%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DRIZyNokDw9o&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FRIZyNokDw9o%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/ea7cdb533fae93d4c91c927293d7b074/href">https://medium.com/media/ea7cdb533fae93d4c91c927293d7b074/href</a></iframe><h3>Discussion</h3><h3>Issues and Challenges</h3><h3>Bad frames:</h3><p>There will be some frames where no lanes will be detected or the lanes might not make sense. We determine the bad frames if any of the following conditions are met:</p><ol><li>No pixels were detected using the sliding window search or search around the previously detected line.</li><li>The average gap between the lanes is less than 0.7 times pr greater than 1.3 times the globally maintained moving average of the lane gap.</li></ol><p>Actions:</p><ol><li>Perform a sliding window search again (this is done in the detect_lines function)</li><li>If this still results in a bad frame then we fall back to the previous well detected frame.</li></ol><h3>Smoothing by Averaging lanes:</h3><p>The lane for each frame is a simple average of 12 previously computed lanes. This is done in the get_averaged_line method in the code block below.</p><h3>Points of failure &amp; Areas of Improvement</h3><p>The pipeline seems to fail for the harder challenge video. This video has sharper turns and at very short intervals. Future improvement:</p><ol><li>Choose a smaller section to take the transform since this video has sharper turns and the lenght of a lane is shorter than the previous videos.</li><li>Make it more robust. Fist is a better binary mask calculation. Second, is a better mask calculation approach. But I do not think these manual crafting approaches are the best. I think that instead of trying to figure out the best set of hyperparameters by hand, it is better to let the computer figure it out automatically.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=faa3084492eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>