<?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 Volkan YILMAZ on Medium]]></title>
        <description><![CDATA[Stories by Volkan YILMAZ on Medium]]></description>
        <link>https://medium.com/@yilmazvolkan?source=rss-3c72b30c665e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*s6Rg0m4VYLAYHVFwsJkNYA.jpeg</url>
            <title>Stories by Volkan YILMAZ on Medium</title>
            <link>https://medium.com/@yilmazvolkan?source=rss-3c72b30c665e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 23:08:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yilmazvolkan/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[Kotlin: Get Android Contacts List]]></title>
            <link>https://medium.com/@yilmazvolkan/kotlin-get-android-contacts-list-3e5b315d47ca?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e5b315d47ca</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[rxjava]]></category>
            <category><![CDATA[contact]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Wed, 01 Jul 2020 19:14:52 GMT</pubDate>
            <atom:updated>2020-07-07T11:26:07.745Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kotlin: Get Android Contacts List Fast</h3><p>Getting contacts can be used in several different applications such as music, contacts, and sticker applications. Today I will share my experience to retrieve and show contacts list in two ways: slower and faster methods in Kotlin. I have found several blogs and code examples on the Internet however I couldn’t know which one is more efficient until I tried some.</p><p>Let’s start with the slower method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/04488a0301ce7a1b5ec6e1c970bf48ad/href">https://medium.com/media/04488a0301ce7a1b5ec6e1c970bf48ad/href</a></iframe><p>In slow method, I use RxJava to perform query in backgorund thread. Inside, I created a simple cursor for query and additional query for contact details.</p><p>I need lastHeader since I want to create headers for each letter A-Z. Thus, first <em>ContactItemViewState </em>object is for header and the second one is for a contact.</p><p>This method might fetch some contacts twice and therefore we need to check first before adding it to our list.</p><p>Finally, we need to close two cursors before the passing final list in onNext() method of Observable.</p><p>Here is the faster method:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/717bbe84ad3e3e302bc87aff75050b47/href">https://medium.com/media/717bbe84ad3e3e302bc87aff75050b47/href</a></iframe><p>Here we do not need the second cursor because our first query is more complex. Let’s look at it closer. First, I created string array of required column names for query to retrieve and we pass it to query as second argument. Third argument is a condition for selection. Contacts objects with phone numbers are valid. Finally, <em>display_name ASC </em>sorts the query results in ascending order with respect to contact names. We need it because we want to use headers before each letter A-Z. As cursor moves next, we get a new contact</p><p>So how is the performance if we evaluate two models. In terms of run time, first method gets and displays ~200 contacts in 5–6 seconds. That is not quite bad however it is annoying a little. Second method however, gets and displays ~200 contacts in just 1-1.5 seconds! It is 4 times better.</p><p>I used RxJava3 to perform this query in background process using disposable. To get the result array we need a disposable and in subscibe method we can get it like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27cfbdd12b71646469cef6d6e9c74342/href">https://medium.com/media/27cfbdd12b71646469cef6d6e9c74342/href</a></iframe><p>I used progress bar animation for recyclerview while it is loading. You can get such animations very easily from <a href="https://developer.android.com/reference/android/widget/ProgressBar">here</a>. Just add new layout and inside progress bar and when your list is ready to show up you can hide it.</p><p>When you exit you need to close the disposable to prevent memory leak:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c77ead59cbdfb61943789816ff7727f/href">https://medium.com/media/5c77ead59cbdfb61943789816ff7727f/href</a></iframe><p>Thank you for reading this article. I hope you enjoyed while reading and learn how to get contacts easily and fast for your projects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e5b315d47ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Line Chart]]></title>
            <link>https://medium.com/@yilmazvolkan/kotlinlinecharts-c2a730226ff1?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2a730226ff1</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[line-charts]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[charts]]></category>
            <category><![CDATA[mpandroidchart]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Wed, 27 Nov 2019 13:15:25 GMT</pubDate>
            <atom:updated>2019-11-27T16:02:09.546Z</atom:updated>
            <content:encoded><![CDATA[<p>Today I will share my experience on drawing line charts in Android with Kotlin. When you want to develop a stock market application or show a statistical data about a user, you will need great line charts for your application. In order to view line charts in Android application, you need to add external libraries.</p><p>After deep research on the Internet, I was able to get some knowledge about several libraries to draw such charts in mobile applications. There are planty but most of them have few features and when you need additional things in your application, you are going to need to change your library and your application accordingly. After careful comparison among the android chart libraries, I believe this special library wins this contest.</p><p>You can find this libary by clicking on the link : <a href="https://github.com/PhilJay/MPAndroidChart">MPAndroidChart</a>. By using this special library you can draw excellent line charts on your application. I put some examples below that have been shared on project repository. After some time you can get such charts quickly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*0XhTDZnUVfFVrBpdr9vVIg.png" /></figure><p><strong>So how are we going to implement such charts?</strong></p><p>First of all you need to add library to your project with following lines:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a46b2368a3e9ba007ec5b30ce07d5c7/href">https://medium.com/media/2a46b2368a3e9ba007ec5b30ce07d5c7/href</a></iframe><p>You need to add maven both in <em>allprojects</em> and <em>buildscript </em>in <em>build.gradle</em> file.</p><p>After this step you are good to try it out! In order to add a line chart to your layout file, you just need to copy this into your layout file. You can adjust size and margis with respect to your design.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b30797fcf81f6d5c5c2d870a6b2a9acd/href">https://medium.com/media/b30797fcf81f6d5c5c2d870a6b2a9acd/href</a></iframe><p>Here I added a line chart into a linear layout to restrict height of the chart and make it compatible with other layouts but you can use other layouts too! However if you want to add a background desing, I would recommend to add a linear layout and assign a background to it. My example gradient file as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f8df4d2098b8016b4cb5a54d28a8485c/href">https://medium.com/media/f8df4d2098b8016b4cb5a54d28a8485c/href</a></iframe><p>Don’t forget to create <em>colorLight</em> and <em>colorDark</em> values in your <em>colors</em> under values. Therefore, our design will look much greater. The second step is completed, now continue with the next step!</p><p>In this step, we implement <strong>Kotlin</strong> code to assign values to our line chart. I divide my example into several parts to show each step and the written code effect on our chart.</p><p>In part1 and part2, we simply create our example dataset. With the last version of <a href="https://github.com/PhilJay/MPAndroidChart">MPAndroidChart</a> library, our data should consist of float values.</p><p>In part3 we assign our list to L<em>ineDataSet</em> and label it.</p><p>In part4, I set draw values to false because to each point it shows a corresponding value in the chart and for long term, it is going to be messy. I set draw filled true to fill below of my chart. I adjust my chart line width and select filled color. You can try them seperately to see how your line chart changes with each code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/975a0ea2624753389e3f3fb5104e8552/href">https://medium.com/media/975a0ea2624753389e3f3fb5104e8552/href</a></iframe><p>In part5, I set label rotation angle to x axis. It <em>sets the angle for drawing the X axis labels (in degrees) basicly.</em></p><p>In part6, I assign my dataset to line chart in the layout to draw.</p><p>Normally, line chart has two y axis, right and left sides and to remove right axis you should add part7 code in your project. If we want to show the last value you also need to add a small margin in your axis limit. If you do not, last value will not be shown in the chart. In this way, you are now able to monitorize all the values in your dataset.</p><p>Since a phone screen is relatively small, people want to zoom in and move around the chart. To enable these features, you just need to add Part8 to your project! You can see this charts as examples:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FftqZE69xn9RMVNL0TP%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fkotlin-ftqZE69xn9RMVNL0TP&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FftqZE69xn9RMVNL0TP%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="241" frameborder="0" scrolling="no"><a href="https://medium.com/media/49138184b854e8b4764add2d5fcf90b6/href">https://medium.com/media/49138184b854e8b4764add2d5fcf90b6/href</a></iframe><p>In Part9, when your dataset fails and you want to write to your screen that there is “something went wrong” thing, you can add it into your project. Description is good for readers to understand what this chart demonstrates. So far our example creates a line chart like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*f_nhAKgCUXZU8tSqioZtdA.png" /></figure><p>In Part10, we can add animation to show while the dataset is loading into our screen. Animations only work for API 11 and higher and all charts types support animations. Three different animation types exist:</p><ol><li>animateX(miliseconds) : Animates chart values on horizontal axis, left to right.</li><li>animateY(miliseconds) : Animates chart values on vertical axis, bottom to up.</li><li>animateXY(miliseconds, miliseconds) : Animates both vertical and horizontal axis.</li></ol><p>There are lots of easing options and you can find more details about animations from <a href="https://github.com/PhilJay/MPAndroidChart/wiki/Animations">here</a>. Part10 code creates a result like this:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FZEBsdl2H4WMULTc9sF%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Fkotlin-linechart-ZEBsdl2H4WMULTc9sF&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FZEBsdl2H4WMULTc9sF%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="241" frameborder="0" scrolling="no"><a href="https://medium.com/media/36005e304b09d94b96aee8d7a926c831/href">https://medium.com/media/36005e304b09d94b96aee8d7a926c831/href</a></iframe><p>In Part11, if we want to show our values on the linechart, we can create custom marker for that. This <strong>marker</strong> works like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*0lXGvC0B-3SdrO_8nqVQBA.png" /></figure><p>To do this first create layouts for this. This code block is to show values in the screen. We create a text view to assign each value.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8d3393579c09aee86c5ca1c5840edd9c/href">https://medium.com/media/8d3393579c09aee86c5ca1c5840edd9c/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee86111be04598de84b21a5e79a6fe56/href">https://medium.com/media/ee86111be04598de84b21a5e79a6fe56/href</a></iframe><p>This is the custom background for your <strong>marker</strong>. After adding these layouts, you need to create <em>CustomMarker.kt </em>to control your marker functions as follow:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/90a77a03cc8419d7821a2f69fb6f4628/href">https://medium.com/media/90a77a03cc8419d7821a2f69fb6f4628/href</a></iframe><p>Here gettOffSet function controls where this markers is located in the chart. I made it right above the circle it points. Moreover, you can set your text view value in refreshContent function. After adding these, to add this custom marker to your line chart you just need to add part 11 to your project! Our final result as follows:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FXcB2eIbVlMCKj7aOnJ%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FXcB2eIbVlMCKj7aOnJ&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FXcB2eIbVlMCKj7aOnJ%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="239" frameborder="0" scrolling="no"><a href="https://medium.com/media/171075c34a302cf7834d64cca57dca54/href">https://medium.com/media/171075c34a302cf7834d64cca57dca54/href</a></iframe><p>I hope you enjoyed while reading this article and learn how to add great line charts to your projects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2a730226ff1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kotlin Sign up and Sign in with Retrofit Tutorial]]></title>
            <link>https://medium.com/@yilmazvolkan/kotlin-sign-up-and-sign-in-with-retrofit-tutorial-c96ca14f06c4?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/c96ca14f06c4</guid>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[tutorial]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Sat, 26 Oct 2019 08:37:02 GMT</pubDate>
            <atom:updated>2019-10-26T08:54:21.944Z</atom:updated>
            <content:encoded><![CDATA[<p>Kotlin is rapidly gaining popularity among android developers. It is native mobile language and it has lots of advantages over Java. Java is 20 years old and since each new version should compatible with old versions, it prevents Java to progress more. Kotlin is however very young language and interoperable with Java. Same tasks can be done with less effort and with short code blocks. Kotlin compiler is more advanced and safer. Moreover, a lot of IDEs support Kotlin language now.</p><p>Retrofit is REST client for android. We use it for connection with API. It makes our task relatively easy to retrieve data and upload JSON objects. Retrofit uses the OkHttp library for HTTP requests. To use Retrofit library, we need to add some libraries into our project. In order to do this, you just need to add them in build.gradle file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfdde1a021650c1a8463afc1b540cc63/href">https://medium.com/media/dfdde1a021650c1a8463afc1b540cc63/href</a></iframe><p>We need the Internet permission in <strong>Android Manifest.xml.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54d4a4b4716ad69fb872988fa9cb2ed1/href">https://medium.com/media/54d4a4b4716ad69fb872988fa9cb2ed1/href</a></iframe><p>After you add them successfuly, you might create an API package and inside that a RetrofitClient.kt class. We initialize Retrofit Instance. We will use it to determine requests and API connection. This file should look like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62c99f635e63ab96ab208bcd4195f4e0/href">https://medium.com/media/62c99f635e63ab96ab208bcd4195f4e0/href</a></iframe><p>In interface you can determine the call structure. We determine there will be a JSON object coming from backend. POST makes a POST request to relative URL of the endpoint. We should determine models or data classes.</p><p>In models package, we can create UserBody data class simply:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aac06139c6b1c00ee8db4d215a4053aa/href">https://medium.com/media/aac06139c6b1c00ee8db4d215a4053aa/href</a></iframe><p>In this example, we just request 5 fields when a user wants to register to our system. In another example, I use sign in and we request 2 fields in login screen. For this function we just need a data class like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cc6feda11007f0a0f9fe7878426ddf1/href">https://medium.com/media/4cc6feda11007f0a0f9fe7878426ddf1/href</a></iframe><p>When you validate your user credentials, you can call signup function in register activity:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aea53be364b6da67f1f8990e6aabbe91/href">https://medium.com/media/aea53be364b6da67f1f8990e6aabbe91/href</a></iframe><p>I put Toast messages to highlight each function. And sign in function should like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62f647b29ae27a0be1b9174f5c4e4ef8/href">https://medium.com/media/62f647b29ae27a0be1b9174f5c4e4ef8/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c96ca14f06c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Northern Lights Trip]]></title>
            <link>https://medium.com/@yilmazvolkan/northern-lights-trip-e31b4192f47d?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/e31b4192f47d</guid>
            <category><![CDATA[sweden]]></category>
            <category><![CDATA[norway]]></category>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[aurora]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Tue, 03 Sep 2019 12:03:07 GMT</pubDate>
            <atom:updated>2019-09-03T13:44:15.943Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Northern Lights Trip</h3><p>The northern lights are fascinating. When you see them, you feel they are from outside of the world and you cannot believe it is someplace on the earth. Under the sky, you witness one of the most beautiful nature event. Even when the weather is cold, you forget all your troubles and watch them peacufully. You see the stars behind the northern lights and with this all green atmosphere, you feel you are on a different planet in the univerve for some minutes.</p><p>My trip starts from Stockholm. Stockholm is the capital of Sweden🇸🇪. Sweden pioneer the Scandinavian culture and economy growth and Stockholm is one of the good spots to explore this culture.</p><p>Our plane land off Arlanda airpot in Marsta, a small town and about 45km away from Stockholm on 16 Jan. Temperature is around minus 7 degrees. To get the city center you need to first take a bus from airport to Marsta and then get on train. All the touristic points in Stockholm are well located and therefore we don’t need to take a daily public transport pass or similar tickets. Our place to stay is in Norrmalm area, near to river and easy to access these touristic places. Most of the royal and historical things are in the old town called Gamla Stan and you need to choose your accodomation respectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l3Ok01cO5PQCKh7fTqWREA.png" /></figure><p>We start with Sergelfontanen. It is beautfiul at night with different colors on it with light show. This area consists of several shopping stores and offices. Also several restaurants. You can see some lion sculptures in the streets. They are somehow famous. Swedish coat of arms consists of two lions holding the crown. Recently, this area is in under construction and roads might be very complex.</p><p>We walk towards to Gamla Stan and Gustav Adolfs Torg public square welcomes first before you step in the old town islands. After taking some photos with this beautiful sculpture, you can now pass the first bridge called Norrbro.</p><p>In Gamla Stan, you can see royal palace first and then you can explore square which Storkyrkan resides. You can see royal guards in this area because they protect the palace and neighbor places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zFHVBu6KUtnG9B_-bkg7YQ.jpeg" /></figure><p>Afterwards, you can walk towards iconic and historical Stortorget public square. You can explore Nobel museum or you can try traditional desserts in Chokladkoppen cafe. There are some seasonal desserts such as Semla, only a couple of days in a year you can eat this delicious dessert in there.</p><p>Since my main point is on the Nothern Lights, I don’t want to give more about Stockholm. You can explore other tourist spots which can be found on the Internet and you can catch nice shots from bridges and boat tours.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-LG6zBrZuehz8LjmHlXVw.jpeg" /></figure><p>After 2 days which is enough to explore Stockholm in my opinion, our next flight is to Kiruna, the Northest point in Sweden which has an airport. Our purpose is stay and explore Kiruna for a day and then go to Abisko.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zWjsupnxd-6WQqkqnM2HTQ.png" /></figure><p>Kiruna is a beautiful northern city and very cold, -30 degrees in Jan. Airport is very small and there is two ways to go to city center. One with the bus and the other with the taxi which is quite expensive (not recommended). We take the bus and as a small note bus goes towards the train station if you want to pass Kiruna and arrive Abisko directly. Kiruna is quite silent and cold city. Peope here don’t walk in the streets much at night in winter I belive and you can see the sun only a few hours here but great location to explore winter season nonetheless.</p><p>Actually we might see northern lights from Kiruna however we face a very thick cloud cover and in order to see them, sky must be clear. You must see the stars. We walk at night to avoid city lights however it is very cold and cloudy.</p><p>After one good day in Kiruna, we arrive the train station towards the Abisko. We use SJ for train transportation and you can purchase tickets online <a href="https://www.sj.se/en/home.html#/">here</a>. We will stay Abisko guesthouse for 2 nights. It is very warm atmosphere because you can talk and meet with people who wants to see the northern lights just like you and get some useful information etc. Also you can purchase some souveniers from the hostel to your friends. Most importantly, they provide real antartic clothes for cold free of charge and you are going to need them absolutely.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1gAhnwt6h_J4Td5wEZUO4A.jpeg" /></figure><p>What makes Abisko <strong>the best place</strong> in the world to see the northern lights? Firstly, there is a very little light pollution in Abisko especially if you stay in Abisko guesthouse. Secondly, Abisko is located among the high mountains and near the lake, therefore it is said that you have high chance to get clear sky withoud clouds. I believe it originates from these mountains that may prevent winds. Moreover, you can barrow clothes from Guesthouse (as a small note even if you aren’t staying at Guesthouse you can barrow still) and Tornetrask lake is very close-10 min walk and the best point to see the northern lights.</p><p>Unfortunatelly, we couldn’t see the norhtern lights clearly because the cloud cover is very thick. We stay on Tornetrask lake which is frozen since the temperature is around -25 degrees for 3 and half hours. We catch a little luminous effect on the sky and see the green things on the gap among clouds. This moment is special since we see the Northern Lights with naked eyes for the first time. It is absolutely outstanding.</p><p>However we are not upset so much because we know that you cannot expect always excellent sky because this geography is wild and we have still some cards to play.</p><p>Our next location is towards the Narvik, Norway🇳🇴. I really like Norway flag due to colors and it reminds me the snow and winter. Narvik is the norhtest point that has railways. After this location you cannot reach further north by train anymore. So you need to take a bus. Narvik is very big city and you should not expect to see the northern lights from here due to light pollution. We reserve one night here to explore around. However there is not much to do in Narvik. You might try the snowboarding in the mountain and it is very close the city center.</p><p>Next location is Tromso and it is crucial for us because we reserve 2 nights here and they are the last nights in north. We hope the see the northern lights here. Fortunatelly, I check the KP index which is essential to follow sky and it tells for 2 days the sky is clear and we have a very high KP index reaches 5. From my experience and the information I read, best hours are around 20.30 to 23.00. Therefore, we decide to explore the city until 5pm, have dinner, and leave home around 7pm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wa0FUlz97vqMyqvCnA9ypw.jpeg" /></figure><p>We plan to climb the mountain however they say cable car is closed after 8pm or so and since this timing is not suited to our schedule, we look for alternatives. I talk with some locals and a friend helps us to select the best point. He was born in Tromso and lives here more than 20 years and he said we were playing games when we are young: Holding breathes respectively until one northern light wave is gone. It is crazy! He suggests a lake called Prestvannet and it is located a little up however you can walk for 10-min.</p><p>We arrive the lake and locals are skiing around the lake on walking roads since they are covered with snow. Therefore it is very slippery and you should be careful. It is very different scenerio though, we are not familiar with skiing outside of the mountains however Norwegians accustomed to skiing in daily life. When you climb towards the lake, you can see some people also try to capture some pictures. If you go there early, you might get the best point around the lake. However, in this case your fingers and feet gets frozen if you are not moving. You need to adjust these variables according to you situation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Is9TAX3wUvftTL2vOHHasQ.jpeg" /></figure><p>We were lucky and see the northern for 2 nights here. You should have a pro camera to capture these lights. Otherwise, your photos is going to be very blurry due to low light. The norhtern lights moves very quickly and changes fast, therefore you need to make some changes on exposure time etc. Moreover, you should also use tripod for camera because when it is recording it is best to camera is not shaking. It causes blurry images too. We are lucky also because we also see the the red-purple light waves too. When the KP is very high you might see them also but they are moving very fast and disappear in a few seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JmNUXimRtOADxJeXxF2Ayw.jpeg" /></figure><p>Chasing the Norhern Lights towards further north also makes this journey exciting. Exploring both winter and northern cultures gives you new perspectives. I put some pictures that we capture. Since we are not experienced with DSLR before and due to cold, we capture what is our best.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e31b4192f47d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dataset Generation: Photo Sketching with GANs]]></title>
            <link>https://medium.com/data-science/dataset-generation-photo-sketching-with-gans-b94ce53d59c1?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b94ce53d59c1</guid>
            <category><![CDATA[sketch]]></category>
            <category><![CDATA[dataset]]></category>
            <category><![CDATA[gans]]></category>
            <category><![CDATA[style-transfer]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Tue, 02 Jul 2019 09:43:12 GMT</pubDate>
            <atom:updated>2019-07-03T12:38:15.491Z</atom:updated>
            <content:encoded><![CDATA[<p>Data is the core to our ML and DL models. We cannot build strong programs if we do not have the proper dataset to train our algorithms. Most of the time, having a dataset enough to train a model is the bottleneck and hard to deal with it especially if we require a dataset that consists of images. To cope with this problem, we need to perform some deformation mechanisms, image manipulation techniques, and other techniques in augmentation. However, we might still end up with scarce dataset for a specific problem. One solution might be creating the dataset just like hand drawn shapes with GAN. Today, I want to examine Photo Sketching in Python with GAN that helps to create such new images.</p><p>To begin with, <a href="https://www.ri.cmu.edu/wp-content/uploads/2019/01/Li-Mengtian-WACV-2019-Photo-Sketching.pdf">this paper</a> is published recently in <strong>Carnegie Mellon University </strong>and studies about photo sketching and gets amazing results. Edge-like visual representation is simply image edges, object boundaries and line drawings. Main focus is on the salient boundaries to manipulate images in this sparse space to generate more. Therefore we can create contour drawings(sketches) as output from given input images. Contour drawing basically consists of object boundaries, salient inner edges such as occluding contours; as well as salient background edges.</p><p>Moreover, this paper improves the performance to generate contour drawings and boundary-like drawings that points boundary of an object. If you work on hand drawn image dataset, it has lots of potential since we can expand our dataset as much as we want and still we can get very realistic drawings.</p><p>Contour drawings can de described as real-world objects and thus can be considered as an expression of human vision. Comparing to image boundaries, contour drawings tend to have more features such as eyes, mouths, noses etc. I put an example from the paper below that shows the specialities from different detectors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gehwsbhmeZzJ-QhDMKKKnA.png" /></figure><p>Contour drawing is good at to adopt the required artistic style. Therefore, it can be seen as a style transfer application. Furthermore, it is mentioned in the paper that contour drawing is an intermediate representation between image boundary and abstract fine drawing.</p><p>In order to use this model, first thing is to dowload this <a href="https://github.com/mtli/PhotoSketch">repo</a>. You can online explore more from <a href="http://www.cs.cmu.edu/~mengtial/proj/sketch/dataset-viewer.html">here</a>, it creates random samples and the webpage for the project is <a href="http://www.cs.cmu.edu/~mengtial/proj/sketch/">here</a>. You can check example dataset etc.</p><p>After downloading the repo, you need to download pre-trained model unless you want to train by yourself. Since in our problem, we have a scarce data, we cannot train this model. This pretrained model that I mentioned is <a href="https://drive.google.com/file/d/1TQf-LyS8rRDDapdcTnEgWzYJllPgiXdj/view">here</a> and it is trained with 5000 high quality drawings on a dataset of 1000 outdoor images from Adobe Stock.</p><p>After this step, you need to edit PhotoSketch→Scripts→test_pretrained.sh and remove those lines:</p><pre>results_dir ${dataDir}/Exp/PhotoSketch/Results/ \<br>checkpoints_dir ${dataDir}/Exp/PhotoSketch/Checkpoints/ \</pre><p>And create a file and add you pretrained files into PhotoSketch→checkpoints→pretrained. You need to add your source image data into PhotoSketch→examples and generated images will be in PhotoSketch→results in the same directory. I will use a dataset like that since I need to create more hand drawn plottings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*JhSiQjawwZ3Iyx5QHjCspw.png" /></figure><p>To run from the shell, execute these commands respectively:</p><blockquote>cd directory/to/PhotoSketch</blockquote><blockquote>./scripts/test_pretrained.sh</blockquote><p>You can see the process in your terminal. I apply this model into my matplot bar plot data. I need to have lots of hand drawn plots and it is good way to generate some.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*rCY54DXqUTnfIijcDq8QWA.png" /><figcaption>Results</figcaption></figure><p>From the results, we can see the pre-trained model generates great drawings from the input source. You can use them to train your own model further such as object detection, image classification etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b94ce53d59c1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/dataset-generation-photo-sketching-with-gans-b94ce53d59c1">Dataset Generation: Photo Sketching with GANs</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elastic Deformation on Images]]></title>
            <link>https://medium.com/data-science/elastic-deformation-on-images-b00c21327372?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b00c21327372</guid>
            <category><![CDATA[image-manipulation]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[dataset]]></category>
            <category><![CDATA[elastic-deformation]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Wed, 19 Jun 2019 08:21:18 GMT</pubDate>
            <atom:updated>2019-06-28T10:26:23.041Z</atom:updated>
            <content:encoded><![CDATA[<p>Current technology is developing so quickly and we have processing power more than ever. We are now able to keep huge amount of data and process them in order to get relevant information. However, even though we have strong hardware infrastructure, if we don’t have enough data to train our algorithms, we cannot achieve satisfying results. Data is the most important part of the ML and DL problems. All the rapid development in those fields would not be possible if we didn’t have huge dataset.</p><p>Most of the time, we cannot reach lots of different data types that we are seek and we need to create new dataset from the existing ones. To do so, we can apply several techniques and algorithms. Today, I will focus on mostly the image dataset. Images are used for object detection, image classification and other several problems. We need to train our model lots of different versions of the same object type in order to determine it quickly for future purposes. However, we might not have enough dataset, it is the bottleneck of most of the problems.</p><p>To cope with this issue, I found an amazing library in Python. It is called ‘Augmentor’. It has lots of different techniques to generate new images from your dataset. Augmentor is really fast, it can create around 100 images per second. It automates image augmentation. I use Augmentor to create handrawn like bar plottings using several techniques. To begin with, you can install Augmentor quickly via;</p><pre>pip install Augmentor</pre><p>Afterwards, you need to add it to your project and create a pipeline. A pipeline is simply series of operations for image manipualtion.</p><pre>import Augmentor<br>p = Augmentor.Pipeline(&#39;./pathToImages&#39;)</pre><p>Once you instantiate your pipeline object, you can add operations into it. You can find Augmentor documentation <a href="https://augmentor.readthedocs.io/en/master/code.html#Augmentor.Pipeline.Pipeline.shear">here</a>. Examples of operations are:</p><pre>p.rotate(probability=0.7, max_left_rotation=10, max_right_rotation=10) <br>p.zoom(probability=0.5, min_factor=1.1, max_factor=1.5)</pre><p>Each operation has a probability value to specify once an image passes through the pipeline, how likely this operation will be applied.</p><p>If you want to apply fish-eye like operations randomly and don’t want to rotate or zoom to keep some image features, I would recommend a pipeline like this:</p><pre>p.random_distortion(probability=1, grid_width=3, grid_height=3, magnitude=5)<br>p.gaussian_distortion(probability=1, grid_width=3, grid_height=3, magnitude=5, corner=&#39;bell&#39;, method=&#39;in&#39;)</pre><p>I am going to apply this pipeline into my dataset. An example from my dataset is below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*Stee74Oc0yhiB3Pb3j-6Ng.png" /></figure><p>It creates amazing image dataset. I share example results when I apply them to inverse colored Python plottings.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*TeSdBa259weL8Df87M1Nlw.png" /></figure><p>After your pipeline is ready you can call to create dataset by:</p><pre>p.sample(10000)</pre><p>Simply, it creates randomly augmented 10.000 images sample using your dataset and extends your limits. By default, they are stored in output folder in your directory but you can change it when you instantiate your pipeline object. If you want to process your images only once to apply operations on your dataset, you can call:</p><pre>p.process()</pre><p>You can use it to crop or resize your images and to do so you also need to give probabilities 1 to your operations.</p><p>Augmentor also gives lots of different other operations. You can apply geometric and perspective transformation on your images. However, these transformations might cause loss of information on your images as can be seen in a figure below.</p><pre>p.shear(0.5, 10, 10)  #Size Preserving Shearing<br>p.skew_tilt(0.5, magnitude=0.2) #Perspective Transforms</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/332/1*LibXnxqanycjrbGyDWre6Q.png" /></figure><p>In these examples, I also use randomly remove corners since most of the time people will not draw perfect shapes in plottings and edges cannot be apperant in those real drawing. In order to implement this idea, you can use a simple function like;</p><pre>def remove_corners(image):<br>    img=cv2.imread(image,0)<br>    corners = cv2.goodFeaturesToTrack(img, 100, 0.01, 10)<br>    corners = np.int0(corners)<br>    <br>    for corner in corners:<br>        n = random.randint(1,4)<br>        if(n != 3):<br>            x,y = corner.ravel()<br>            cv2.circle(img,(x,y),3,255,-1)<br>    return img</pre><p>I apply this function to my images in the folder. Images on the top is the source dataset and remove corners function applied images is the below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/325/1*_7NJgQrOISFhTHXPyRBAbw.png" /></figure><p>OpenCV is capable of such things easily. It reads images, finds corners inside the image and paint them in order to get rid of them. I add simple probabilistic way to determine 75% of corners from uniform distribution and remove them to add some stochastic approach to our dataset.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b00c21327372" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/elastic-deformation-on-images-b00c21327372">Elastic Deformation on Images</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digital Neuron]]></title>
            <link>https://medium.com/@yilmazvolkan/digital-neuron-3d66b7f10f84?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d66b7f10f84</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[neurons]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Fri, 08 Jun 2018 13:38:49 GMT</pubDate>
            <atom:updated>2018-06-08T13:48:03.815Z</atom:updated>
            <content:encoded><![CDATA[<p>According to University of Queensland description, the neuron is an electrically excitable cell that receives, processes, and transmits information through electrical and chemical signals in nature. One neuron is powerless; however if they connect each other over a million and create a colony, they will produce a powerful computer called brain. With this brain we are able to learn things and whenever there is needed, we can use previous knowledge to accomplish what we want.</p><p>In machine, we have this kind of neuron called node or perceptron. It gets independent variables from input layer as a vector. Independent variables as input are shown as X’s and corresponding weights are w’s. Weights are used to determine what signal is poor or important. When we get the weighted sums and we need to pass that signal, it visits the activation part. Simply activation function decides which signal will pass and which are not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*v_Khr3exIxpCUu8--wwRmw.png" /></figure><p>There are several activation functions such as sigmoid, rectifier, hyperbolic etc. For example, if dependent variable y is binary, we can use threshold or sigmoid function.</p><p>How it works? For example, you have trained your neural network which consist of these neurons for guessing house prices for a website. To determine price of a house we have several criteria: age, distance to city, area, number of rooms etc. In basic we can write y, the price as a linear equation of these variables with their corresponding weights of determining the price. Moreover, we can use these neurons deeply. Sometimes some variables affect the dependent variable in combinations with others. We should use additional layers of neurons to process these combinations. These hidden layers allows more flexibility and makes our model powerful since it allow neural networks look very specific things.</p><p>ý is output value from neural network and y is our actual value. To evaluate our model we need to compare these. The cost function points the error. Our goal is to minimize it. Basically, we will have some difference between ý and y. Once we compared, we will feed this info back into the neural network and weights get updated. Finally, the cost function gets the minimum value. This process is also called back propagation.</p><p>We can implement a digital neuron with object-oriented approach in Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*v4fBSxqIEwsZfM3IM8rMWw.png" /></figure><p>Parameters are; eta is the learning rate which will be between 0.0 and 1.0, n_iter is the number of epochs which determines how many times will it passes over the training dataset, and random state is used to initialize the weights with random number generator.</p><p>Attributes are; w_ is the weights after fitting, errors_ is the number of wrong classifications in each epoch.</p><p>Perceptron object will learn from data via fit method and make predictions via a predict method.</p><p>In fit method, X is the number of features and y is the target value. Using this neuron implementation, we can now initialize new Perceptron object with a learning rate eta and number of epochs with n_iter. Via fit method, we initialize the weights in self.w_ to a vector R^(m+1), where m is the number of dimensions or features. 1 for biasing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d66b7f10f84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning in Outline]]></title>
            <link>https://medium.com/@yilmazvolkan/machine-learning-in-outline-f91f1885f12f?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f91f1885f12f</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Tue, 05 Jun 2018 10:45:53 GMT</pubDate>
            <atom:updated>2018-06-06T09:00:02.828Z</atom:updated>
            <content:encoded><![CDATA[<p>Information and data are abundant in this century and each day it is growing rapidly. We need to cope with this increasing amount of data since we want to extract meaningful information to use it in several applications for users. The first step is making the data structured with data preprocessing because data is not always structured as we have wanted. Then we can process this huge amount of data with machine learning. In the recent years machine learning is gaining fame in order to make predictions with self learning algorithms and derive knowledge. As a result, thanks to the machine learning we can prevent email spams and we have efficient web search, text and voice recognition and self-driving cars.</p><p>We can divide machine learning into three parts ; supervised learning, unsupervised learning, and reinforcement learning.</p><p>In the supervised learning, we have already known the true values for output of the system and the goal is to learn a pattern from the labeled training data and therefore we can make predictions for future data. For example, consider the text recognition, we have bunch of different handwritten shapes for each letter in the alphabet. For input, user gives her/his example of handwritten character and our system will predict the correct letter with certain accuracy by classifying them.</p><p>Classification is one approach of the supervised learning. Based on the previous observations, it finds similarities and separates data into groups. For example, for distinguishing the email spams, according to some criteria the algorithm classify them as a spam or not-spam. It is for discrete outcomes and you use classification to predict a category.</p><p>Regression is another approach of the supervised learning. Regression analysis is the prediction of continuous outcomes with respect to given a number of predictor variables. It is used for predicting a real value, like salary. For example, the SAT scores of students whether there is a relationship between the time they spent on studying and their final scores. If your independent variable is time, then you are forecasting future values. Then, we can derive some relationship and plot this into to chart because it is two variable problem. Sometimes these variables vary. For instance, the price of a house might be determined by the number of rooms, distance to city center, age etc.</p><p>Second type of machine learning is reinforcement learning. This system tries to improve its performance based on the feedback from the environment. Thus we can think it is a supervised learning; however in reinforcement learning, it does not determine whether it is absolute true or false but rather how well the action was measured by a reward function. Like in the maze runner, through its interaction with the environment, an agent learns series of movements to maximize this reward. For example, in a chess game, the reward can be defined as a win or a lose at the end of the game. Each state can be associated with a positive or negative reward. Threatening an opponents piece can be seen as a positive reward and losing yours can be a negative reward in a series of movements.</p><p>The final type is unsupervised learning. In the supervised learning, we know the right answer beforehand when we train our model and in the reinforcement learning, we define a measure of the reward for particular actions by the agent. In unsupervised learning, we can explore the structure of our data to extract meaningful information without the guidance of a known outcome variable.</p><p>Clustering is one approach of the unsupervised learning. You do not know what you are looking for and you are trying to identify some segments or clusters. Objects with certain degree of similarity in one cluster and others are in other clusters. For example, based on the annual income and the spending score, a mall wants to segment their clients. We don’t know how many clusters will be.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f91f1885f12f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creative AI]]></title>
            <link>https://medium.com/@yilmazvolkan/creative-ai-58eccb91999?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/58eccb91999</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Tue, 27 Feb 2018 20:45:07 GMT</pubDate>
            <atom:updated>2018-03-03T10:23:03.040Z</atom:updated>
            <content:encoded><![CDATA[<p>Neural networks are generally good at predicting or classifying things and solving problems. Howewer, scientists also want to create a type of neural network that can create for itself. Generative Adversarial Networks(GAN) can be used for generating images, image modification, super resolution, photo realistic images, speech generation, and face ageing.</p><p>GAN can actually generate images that they are not existed before. GAN consist of generator and discriminator components. Basically, generator creates images, and the discriminator assesses these images, then tells the generator whether those images are likely to be similar to real examples.</p><p>How do GAN work? Generator takes noise signal as input and creates random images. Since we want to train discriminator to make it smarter, we give additional real images. Then, it will give some probabilities with respect to real image. We take these values and look at what they should be. Resulting error backpropagated to discriminator and weights are updated in order to get more relevant images.</p><p>For the second time, discriminator takes new generated images as input without real images. Since the way the generator learns by trying to trick the discriminator and based on it will succeds or not it will update its weights in order to produce similar images. We take these values and look at what they should be. The error backpropagated to generator this time and weights are updated in order to create more relevant images.</p><p>These processes can be implemented on Python with the help of nn.Module class. We can simply implement generator and discriminator one by one and update weights according to resulting error. As an input we can give an image consists of small images. The training and creation of images takes approximately a day and at the end of each epoch we get an output image. At the beginning of process, these images are not seem to like anything since the training is not completed enough. However, while the program is running, we can see coming more relevant images. We can see the result below;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ZaIap7ymgIbVGaqmMcXbQ.png" /></figure><p>The results show us the algorithm learns how to use pixels and creates good images rather than some blur and ambiguous images.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58eccb91999" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Face Detection]]></title>
            <link>https://medium.com/@yilmazvolkan/face-detection-3cfa0a78bc5f?source=rss-3c72b30c665e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cfa0a78bc5f</guid>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Volkan YILMAZ]]></dc:creator>
            <pubDate>Tue, 27 Feb 2018 20:20:31 GMT</pubDate>
            <atom:updated>2018-03-03T09:59:10.147Z</atom:updated>
            <content:encoded><![CDATA[<p>Face detection substantially gains importance since their usage areas are getting wider. These days face detection is used in banks and smartphones to provide more secure systems, in social media and dating apps to match people and tag people easily, and even at schools to take attendance. It is also used in person emolojis with reflecting your shape and mood when you record.</p><p>To start with, face detection can be implemented through Viola-Jones Algorithm. It is the algorithm that lies at the foundation of openCV library and it is very powerful. It consists of training and detection stages. With this algorithm, there is a box that searches certain shapes for a face through pixels. It detects eyebrows, then eyes, then nose and keeps going like that. If it cannot find enough fetures, it understands it is not a face.</p><p>Moreover, Haar like features like scaleble edge,line and four-rectangle features are very important in detecting process. For example, in the face, lip is a line feature since there is a darkness where the two lips are joining and outside this there are bright regions. We can take difference between brightness and darkness to detect Haar like features with certain threshold of this difference. Once the algorithm identifies these features in the face through training, program understands what elements roughly a face is constructed from, then it will be used to detect faces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*pRcW290N290NLydSx2xYtQ.png" /><figcaption>Haar like features</figcaption></figure><p>However, processing Haar like features takes quite some time especially if you have lots of these features. Since they are scaleble, algorithm can find features over 100,000+. Integeral image shortens this process. The summed-area table is the sum of all the pixels above and to the left. In Integral Image algorithm, it calculates how many pixels it has until certain corner pixels and memories them to evaluate difference of brightness. While algorithm is comparing difference between brightness and darkness, throgh integral image feature, it just looks at certain pixels easily. Additionally, while the image size is getting bigger, it again just looks at those pixels without concerning about execution time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*-dVg_MreTVcYX9T-jpTlIA.png" /></figure><p>Furthermore, since these features are scaleble, to prevent variations of features, we shrink input images to detect features for faces. However, even this small pixel images the number of features is still huge. Thus, we need to focus on more important features. There comes Adaptive Boosting. It selects best complements of existing features. When existing features is weaker for some areas, this new feature is strong. Cascading method is also very important. It looks for top certain number of features and if one of them not present, it does not evaluate the rest. It helps speed up the process.</p><p>To goal is find all features to classify all faces and non-faces correctly. Using these steps, we can implement in Python with openCV library. The results are below. We can see in figure 1 the program detects faces with blue rectangle and eyes with green rectangle. Then, in figure 2, if person is smiling it detects and show it with red square whether he/she is happy or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RGkdELF9kl7C0PJiOp18Eg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cfa0a78bc5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>