My Game Design & Development Course Project

I started using Unity for “Game Design and Development” course at Ozyegin University by Prof. Tanju Erdem.
Here is the demo part. I haven’t finished it because of other final exams..

Backing up sdcard of Android phone with adb

Unfortunately I dropped my Nexus 4 today. The front screen has broken. It is not shattered it is in one piece. Even half of the screen works but lower part does not. I had a constant screen lock. The working part of screen wasn’t enough to let me unlock the screen let alone make a phone call. Anyways I have to get a screen.

Now I want to back up all my sd card content and wipe them all before I give my phone to the service. When I connect my phone to PC MTP connection show the device but it is empty. There are no files. The files appears when screen lock is open which I cannot do. I had previously installed Android Device Manager and enabled it. I checked its options there were no screen unlock or backup. However there was a Remove button. Which I will try later. My phone is not rooted. So Nexus Root Toolkit tools didn’t work. If I rooted or unlocked it would delete my data. Finally I found a solution by using a adb command ‘pull’. I think for this to work you need ‘USB Debugging’ enabled from Developer Options on your phone.

Find’adb.exe’ under android sdk folder. Opened a command prompt in that folder: wrote the lines like this
adb pull /sdcard /myBackupFolderUnderC
And it worked! Without unlocking screen lock or doing anything else.. I will take some time to copy all files you will see the filenames on command screen. After copying is done I checked, all the content like photos, DCIM folder, data folder were copied. Then I got back to Android Device Manager of mine:
I selected my device. Your device should be connected to internet for being able to communicate with phone thorugh android manager. If your 3G is enabled or your phone is in a place that has a wifi which your phone automatically connect (home), you are fine. I clicked Delete Phone button in Device Manager. It rebooted and there it is a brand new factory set device. I checked my sd card easily because now internal storage appeared on Explorer(file browser) on my PC. It was totally empty. Now I can give this phone to technical service for changing screen.

In case you drop your phone, I suggest you to install and enable device manager on your phone. And enable USB debugging and at least once connect it to your PC check if adb works. Leave your phone connected to internet if possible. That will save you when you need Device Manager. I hope you don’t break your phone’s screen! :)

Finally starting with my UDOO Quad

I got an UDOO Quad from kickstarter campaign of UDOO last summer. Until now I haven’t been able to play with my UDOO due to reasons. Today I couldn’t keep my self from booting UDOO when I saw that there is a Ubuntu 12.04 LTS SD card image for UDOO. I have lots of project in mind for my UDOO.. But I will do them later since I am actually busy novadays.

Today I wrote the SD image for Ubuntu 12.04 from here:

I connected micro USB to CN6 connector of UDOO for serial monitoring. I put the sd card in slot and connected the 12V power adapter. I opened Tera Term serial terminal program. The booting screen showed up :)

Then I tried to scan for my home wifi. But ‘iwlist’ command was not found. So I had to connect ethernet cable to my UDOO.
For iwlist command which scans wifi, I needed to install ‘wireless-tools’ package.
I had a problem with wifi. I will get back to that later. Right now I am connecting with an ethernet..

Then I installed VNC server as described here:
Now I can finally see my UDOO’s desktop :)

I tried to connect my 1TB SATA harddrive to UDOO but since I don’t have appropriate power cable it didn’t work. I will make the cable later at lab. For now I used my SATA to Usb converter and it worked. I am using harddrive for storage not for boot.
I made a quick case for UDOO. Now it lives in its new house near adsl modem. :)

Export Eagle Schematic and PCB files to Altium Designer

Recently I needed to use a design made in eagle. Since I am more comfortable in Altium Designer, I wanted to export Eagle files to Altium files. I searched on internet to find necessary tools. Luckily I found something. As told in the link below you can run ulp script in Eagle to convert your files to altium files. However I faced with the issue mentioned in the web page. My circuits included lots of “%” signs. Since scripts use printf in C they caused problem. Both scripts caused problem with my files. I checked the schematic script and found a function writter for fixing regarding issue of “%” sign. It was changing “%” to “_”. I modified it to change to “p”. Using this function I quickly fixed both scripts. Here they are:


Source of scripts:

Getting Skeleton data and RGB video in Matlab from Kinect For Windows

Hi, I was working with “Kinect for Windows” for a while. I am using Matlab to get the skeleton sata and process it. I want to share the code that I am using for getting RGB video and the skeleton data at the same time. This code also shows the video with skeleton drawn on it, saves the video and skeleton data at the and of code.
I have Matlab R2013a.



%% Code for acquisition of rgb video and skeleton data at the same time
% Alp Burak Pehlivan -
% Skeleton data and video is saved at the end of acquisition
% This code also can be used for online processing of kinect data
% You need to get this support package for running the code:

utilpath = fullfile(matlabroot, 'toolbox', 'imaq', 'imaqdemos', ...
    'html', 'KinectForWindows');

vid1 = videoinput('kinect',1); % RGB camera
vid2 = videoinput('kinect',2); % Depth camera
srcColor = getselectedsource(vid1);
srcDepth = getselectedsource(vid2);
% Turn on skeletal tracking.
set(srcDepth, 'TrackingMode', 'Skeleton')
% You can get the upper body only if you want to record seated person's data
% set(srcDepth, 'BodyPosture', 'Seated')
set(srcDepth, 'BodyPosture', 'Standing')

% fnum=How many frame we will record from kinect
% This corresponds to the record duration

filename='testdata' % File name for video and also data file
% create video object
combinedStr = strcat(filename,'.mp4');
vidObj = VideoWriter(combinedStr,'MPEG-4');
vidObj.Quality = 100;
vidObj.FrameRate = 10;
% vidObj.FrameRate = srcColor.FrameRate;

vid1.FramesPerTrigger = 1;
vid2.FramesPerTrigger = 1;
vid1.TriggerRepeat = fnum;
vid2.TriggerRepeat = fnum;
triggerconfig([vid1 vid2],'manual');
start([vid1 vid2]);



% Trigger 400 times to get the 400 frames. then stop
for i = 1:fnum+1
    % Trigger both objects.
    trigger([vid1 vid2])
    % Get the acquired frames and metadata.
    [imgColorAll, ts_colorAll, metaData_ColorAll] = getdata(vid1);
    [imgDepthAll, ts_depthAll, metaData_DepthAll ] = getdata(vid2);
%             ts_color=ts_colorAll(1);
%             ts_depth=ts_colorAll(1);

        if any(metaData_Depth.IsPositionTracked)==0

            % representations of skeleton positions on image
            jointIndices = metaData_Depth.JointImageIndices(:, :, skl(1));

            % 3D skeleton joint positions
            jointCoordinates = metaData_Depth.JointWorldCoordinates(:, :, skl(1));

            % Find number of Skeletons tracked
            % nSkeleton = length(trackedSkeletons);
            nSkeleton = length(1);
            % this line draws skeleton on rgb
            % just for showing them in the same image
            util_skeletonViewer(jointIndices, imgColor, nSkeleton);

            % Here we take all 20 joints and put them in data
            for j=2:20,
                data=[data jointCoordinates(j,:)];
            % here 'data' includes this frames' skeleton data
            % you can do some processing here..
            % this will have all recorded skeleton data
            AtrainData=cat(1, AtrainData, data);

       % Writing the rgb frame with skeleton drawn on it to video file
       writeVideo(vidObj, getframe(gcf));

% If you don't stop you can't start video acquisition again. it will give
% error when you try to start again. in this case call fnc below
stop([vid1 vid2]);

% jointCoordinates
% Save the skeleton data file
combinedStr = strcat(filename,'.txt');
dlmwrite(combinedStr,AtrainData,'-append','delimiter','\t') ;

You need to get this support package for running the code:
Here is the MathWorks link for Kinect for Windows examples. I got the main help from here:
You can get the SDK for C++ and C# examples working with Kinect in Windows:

Fixing the Broken Akbil-İstanbul Taşıma Kartı

This part is a story telling- pass to the beyond of dashes below for the fix :)
Few weeks ago my akbil(İstanbul city transportation pass by IETT company) got broken. It was really bad for me since I had a student card which pays discounted fare to bus, metrobus, metro etc.. Getting a new student akbil requires to get a student certificate and visiting an IETT(public transportation company) office. I haven’t found a time to do that. So I used a regular card which pays more. Much more like double amount of student card. :O I felt I really needed to get my student card again. I got an appointment for pass card office. I went there for the card but the office employers told me that “system is down we can’t give you a card, we don’t know when we can”.. That was terrible. Unfortunately things like this happen. And my transportation costs were annoying. So I decided to fix my broken card. Of course I hadn’t thrown my broken card. I was actually carrying it with me still.
Thank for patience you can continue on the Fix below :)

İstanbul city transportation pass Akbil are MiFare DESFire EV1 (MF3ICD41). Here is the datasheet.
My card was broken from one side only but the NFC antenna was broken. So I needed to remove the chip and attach it to some other antenna.
I started scraping the card with a knife because it was made out of PVC. It was a tough material it was impossible to see where the chip is. I guessed some part found antenna parts but all my guesses were wrong. I was thinking maybe the broken part was holding the chip.. Since broken part was missing I lost my hope. Then I started burning the card with the help of a lighter. :D Since I wasn’t able to find the chip. The surface of card got degaraded. I found the chip! :D It was under the part I was burning. I removed the chip hoping I didn’t burn the chip. :) I don’t have any photos of that card because I didn’t think It was gonna work. Also photos may be bad I didn’t plan to document.

NFC chip place in Akbil

NFC chip place in Akbil – NFC Çipinin karttaki konumu

I was in the OzuRobotics lab so I had soldering iron and tools. I tried to solder the chip to another NFC card antenna by removing its chip first. I wasn’t able to solder to the antenna. It was so thin and fragile. Solder didn’t hold either. It was like aluminium. Then I decided to make my own NFC antenna. I found a selenoid. I used its isolated winding wires for antenna.

I believe I did 8 loops with the wire on a paper card. Same size with the Akbil card. Winding loops were the same number in Akbil’s NFC Antenna.
In Order to solder isolated copper wires I burned the ends of wire with lighter. Then I soldered. Eventhough the solder didn’t hold much. By using too much solder I enclosed the small nonisolated ends to other copper wires. Then I soldered these copper wires to the chip contacts.
Before and later I did tests in every step. I made sure that wires were in electrical contact correctly. I checked if NFC was read by a reader using my Nexus 4. It has NFC reader. I used NFC TagInfo App Android application. Finally I put tape on it. Made it robust.
It doesn’t look nice but it works! There was still money in it, I used it on the way back home :)


Selamlar :)
Hikaye kısmını geçip aşağıdaki anlatıma geçebilirsiniz.
Geçenlerde Akbil’im kırılmıştı. Cebimden bir çıkardım akbili çalışmıyor :D Kırılmış kenarından. O 1tl’lik akbil koruma kaplarını boşuna satmıyorlarmış. Neyse. Akbili yenilemek için öğrenci belgesi almam gerekiyormuş. Koşuşturmaca içinde biraz erteledim bu işi. Normal akbil aldım. Öğrenci akbiline alışınca normal akbilin fiyatları çok geliyor. Hemen çıkarayım dedim gittim Uzunçayır İETT ofisine. Vaktim de sınırlıydı zaten acelem vardı. Görevliye söyledim akbilimin yenisini çıkarmak istiyorum diye. Sistem bozuk ne zaman düzelir bilmiyoruz dediler. Ben de kızdım. Zaten zor zaman bulabildim koşuşturmaca arasında. Şimdi öğrenci akbilsiz boşuna fazla para ödüycem diye..
Üniversite’ye gelince bir ara boş vaktim oldu. Hemen aklıma geleni uygulmaya koydum Robotik labında. Akbilin içindeki çipi aramaya başladım. Yüzeydeki kaplamayı çıkardım. Ama PVC olduğu için kart içindeki çipin yerini göremiyordum. Işığa falan tuttum göremedim. Kenarları kazıdım dikkatlice anteni buldum. Zaten kenardan kırılınca anten bağlantısı kopup da çalışmamıştı kart. Neyse Çipi tahmin etitğim alanlarda bulamadım. Ümidimi yitirmeye başlamıştım. Her yeri kazımıştım. Önceden kırılan bir kısmı kaybolmuştu. Belki de çip o parçanın içindeydi diye düşündüm. Çakmağı aldım kartı yakmaya başladım :D Nasıl olsa çipi bulamıycaktım. Kart yanarken şekli bozulmaya başladı yandığı yerde bir kısımda çip ortaya çıktı. :D Hemen söndürüp çipi çıkardım.

Anten olarak tek kullanımlık akbillerin antenini kullanmayı denedim önce. Onların fotoğrafı yok sanırım. Kağıt oldugu için ışığa tutunca içi görünüyor. Küçük bir çipi var. Onu kestim kağıdı kazıyarak antenin iki uçuna denk gelen yerleri açığa çıkardım. İnce bakır tel lehimlemeye çalıştım. Olmadı. Lehim tutmadı. Anten aliminyum gibi ince bir metal. Sanırım. Bakır olsa lehim tutması lazımdı. Neyse. Baktım bu iş ümitsiz. O zaman başka çözümler aradım. İnternette aradım kendimiz yapabilir miyiz anteni diye. Pek bir şey bulamadım ama düşündüm. NFCnin sonuçta indüksiyon akımı ile çalışıyor. Bir kaç tane sarım sarsam denesem belki çalışır diye. :p Çok da emin değildim. Ama yanımda NFC okuyuculu Nexus 4 telefonum olduğu için deneme şansım vardı.

Anten için uygun teller aradım. Plastik kaplı ince bakır tel denedim. Olmadı. Labda benim malzemelerim vardı. İçinden bir röle buldum. Rölenin selenoidini bozup açtım. Uzunca bir tel çıkardım sarımdan. Karton bir karta yukardakı resimlerdeki gibi sardım. Lehimleme kısmı yine zor oldu. Bu ince yalıtımlı teli lehimlemek için önce çakmakla boyasını yaktım. Denedim multimetre ile iletiyormu diye. Lehim boca edip lehimledim. Bakir tele. Bakır teli de çipe lehimledim. Her aşamada denedim iletim sağlanıyor mu diye. Bir de telefonumla NFC reader Applicationu ile denedim çalışıyordu :D Bantlayarak sağlamlaştırdım kartı. O gün bu gündür (1.5 haftadır) kullanıyorum sorunsuz. Yalnız bazen yavaş okuyor kart doldurma makineleri biraz :p ama olsun.

How to Install OpenCV for Qt Creator in Windows?

In this tutorial, I will tell you how I used OpenCV in my Qt application in Windows. (I use Windows 7)

1- Download Qt Creator for Windows. I installed the one with MinGW.
Qt 5.1.0 for Windows 32-bit (MinGW 4.8, OpenGL, 666 MB)

2- Download MinGW. Install.

3- Download CMake. Install.

4- Download OpenCV Source. I installed OpenCV 2.4.6
Extract the files somewhere. I directly extracted to C:\. When files are extracted installer will close by itself.
You should have the souce folder like this:

5- Now creating MinGW make files by cmake-gui. Run Cmake gui from program files.
Select the folder for source files as C:\opencv
Select the folder for build files as C:\opencv-mingw

6- Click Configure Button. It will ask for generators. Select “MinGW Makefiles” and “Specify native compiler” options.

7- Select compilers from Qt creator folder where you installed. Compilers are in Tool folder under mingw48_32/bin
For C select: C:/Qt/Qt5.1.0/Tools/mingw48_32/bin/gcc.exe
For C++ select: C:/Qt/Qt5.1.0/Tools/mingw48_32/bin/g++.exe
Click Next

8- Now cmake will prepare the configurations. In this part I got several errors in my previous attempts. One if them was about python library. Something like pyhton25.dll not found – i don’t remember. I saw a comment saying “opencv only works with python lower versions than 3. So I erased existing python library. I installed new one python 2.7. Restarted cmake process again. It worked without errors this time.
I got an output like this: Click Expand Code to see all of it.

We will choose options we want for OpenCV build. For my build I deselected WITH_CUDA. Other than that I didn’t change anything. Now Click “Generate” button to generate makefiles.

If you got no error in generating makefiles you can close cmake. Now you should have a build directory like this:

9- Now we are at the compiling stage. Open MinGW Shell. Go to your build directory and type make command like this:

This will take some time.. Go kill some titans :D
Hopefully if you can compile without any errors you will get a screen like this:

10- Now make install.


11- Now you should have dll files in your opencv install folder like this: C:\opencv-mingw\install\bin
If you have them that’s great! :) You have installed OpenCV.

12- Now lets switch to Qt. Open Qt Creator. If you have already have a project just add these lines to your .pro file for adding OpenCV libraries:

What we do here is:
1- define the include path.
2- define the lib path
3- and tell which libraries you are going to use by library names.
library names of opencv : you can use dll names without “lib” and add “-l” in front. for example: libopencv_videostab246.dll => -lopencv_videostab246
Now you are good to go!

If you dont already have a project in Qt with OpenCV, just now I prepared a simple sample project for you people who wants to use OpenCV in Qt applications. I included a nice function to convert Mat images to QImage for displaying them in Qt Gui.
Here you can download it an run it if you followed this post until here.
You can find the code On GitHub
Repository :

qt opencv edge detection

qt opencv edge detection

I hope this was useful to someone. I struggled a lot during my trials. :)
This post was too long, so I will tell about more on Qt, OpenCV, and libraries in another post. Happy coding :)

I am in Japan! :)

Hello, since my last post a lot has happened. As a result I am engaged now with love of my life :) and I am in Japan for 3 months. I am doing research in DBI lab in ATR,Japan now.

ArDrone – Color tracking and Technology Minister

Minister of Science, Industry and Technology, Nihat Ergün visited our lab, OzuRobotics on thursday.
I showed him Quadrotor -Ardrone with color tracking. He tried it himself too. There are Hüsnü Özyeğin and rector Dr. Erhan Erkut with minister in photos.

Actually I put a video of Ardrone-color tracking on Youtube. Here you can watch it.

Electrical door lock trials at Base Istanbul

Today Zeynel and I tried to make an electrical door lock system :p We wanted to open and lock the door of Base by a motor. We didn’t have much tool in the Base for mechanical work. As engineers we found a way construct something useful. We had a dc motor with reductor. We thought it would have enough torque to turn the key. We had to connect the key to gear somehow. We built this:




We used screws and other metal parts from Mahmut’s old robot :D Sorry Mahmut! You should write “don’t disassemble please work going on” or sth. :) otherwise in a hackerspace, everything can be torn in to pieces and used for projects. :)
In the end, It didn’t have enough torque to lock and unlock.. Next time we will find another solution.