Sunday, 24 December 2017

Week 14: Last week~

Greetings guyss its been week 14 and sad to say that it is the last week of the semester. This semester had been great, special, surprise and full of discovery with this open lab session prepared by our lecturer. Okay...let's have some update here...

Following from last week where my lecturer, Dr.Woon gives me a "discount" where I only need to code a programme which can calculate the sharpness of an image so that we can compare two similar/non similar image in term of their sharpness, glad to say that with the implementation of opencv library, code block and cmake (all those which I installed last week) had allowed me to success to come out with what Dr. Woon want.

Curious what does it looks like?? Worry not! Lets have a look on the pictures below. Basically, I created myself three image samples to test with, name it:
1) Clear
2) Blur
3) Very Blur

Lets test the image sample "Clear" first. As this is the clearest image among the three sample of mine, it therefore should give the highest sharpness value...

First sample. Clearest image.

Well yeah, the result shows sharpness of 0.999943. Hmm...not too bad, but who knows thats the highest value among three samples? Let's continue...

                                                   


Second Image Sample. Titled "Blur"


Okay, now that the sharpness shows 0.999875, it is what we expected, which is lower than the first sample (woohoo!!) This proves that we are half way success in testing our code already! If the third sample "very blur" shows lowest value, then our code works! Lets see!! (nervousss)

Third Image Sample. Titled "Very Blur"
Yess!! The sharpness show the lowest value among the three samples!! This means our code can works in order to measure the sharpness of an image and thus compare them!

And of course, the consistency is also tested. This can be done by running the same image for several times and the sharpness value shows the same for the same image, which is a good thing. 

Well guys, that's all for this semester. I hereby hope anyone that is having study week now all the best and do your best in the upcoming final exams! And for those who are still on their lecture weeks, always pay attention to your lecturer in class and remember to submit your works on time! For non students, I hope all of you stay healthy and happy always. And not to forget, MERRY CHRISTMAS EVERYONEEE~~~ ^.^!!

I will like to thanks a lot of people throughout this 14 weeks projects. First of all, my lecturer, Dr.Woon Kai Lin which give us the opportunity and platform to practically do something we seldom do. Open lab session is a great opportunity for students to get in touch with the practicals and develop student's interest and also talents. KLESF is also a great platform for student to show their work to the public so that we can have the sense of achievement and confirmation. Also thanks for Dr. to guide me, understand my situation/problems and give the best advice and resource in order for me to walk out from the jungle of lost. Again, thanks for all the effort Dr..

Next, I will like to thanks all my teammates from team Sotong (yes I didn't forget all of you although its only 7 weeks we are together), thanks for enduring me, showing up whenever I called up for meeting at some random time and helping in the projects, your effort are really appreciated and happily we managed to born our own microscope muahahahah!!! 

Also, I would like to thanks Raqif senior, he is a material science graduate years back and have experience working with Android. He really helped me a lot in term of Android Studio and Java coding as from the beginning I have zero knowledge on those things. Despite of busying with his own work, he still willing to spend some time with me to help me in my hard time. And also thanks for introducing me in to the Android community in Telegram, I have really learned a lot from the masters there and I will not quit that community because I am sure I will definitely learn alooooooot more from the community in the future HAHAHAH!!! Okay seriously I really really appreciate all of the efforts ^.^.

Not forgetting my friend from FSKTM, Siong!! Hahah!! Thanks for giving me advise and guides in coding and software parts. Also he helped me with identifying various computer/compiler error showed up whenever I am clueless. Yeah as for those who worked with programming knows, the most scariest thing in this world is not ghost, but error that you never seen before pop out from nowhere. But the sense of joy and happiness when the error is solved and the moment you know the reason of the error is something money, credit cards, bitcoins or any property cannot buy!! XDD

Lastly, thanks to the Telegram community that taught me a lot of new things whenever i appear with questions. The guides you guys gave me are really clear and helped to solv my problems. 

That's all guys. Good luck !!



Monday, 18 December 2017

Week 13: When situation is not favorable, find ways!

Haiii guyss....it's week 13 here and here we come for another update again~

As for those who followed the previous week's post should know, I have met really a lot of obstacles while in the progress and it is really hard to complete the whole project by week 14. However, thanks to my lecturer's understanding toward my situation, he did gave me some "discount" on my current work, which really bright me up in the darkness (WOOHOO!!).

First, back to the camera part following from last week's post. As from last week, everything about the camera is developed but somehow, the camera did not work at the way it should and it really cost me a lot of brain juice to diagnose where is the problem. At the very hopeless stage, I decided to try the only thing I never tried before in diagnosing the problem, which is, to install the apps in another Android phone. Miraculously, the camera apps works fine and good in other Android device (Samsung A5 2015). The camera apps is able to be opened smoothly, takes full size picture with no pixelation and are able to store the image in the gallery with time stamp as the image name. After some discussion with my senior, Raqif, which previously helped me in developing the code, we believed it is because of the non-compatible API on my Android device (Samsung galaxy Note 5) which had caused the problem. Also, from the discussion with my lecturer, we believe that there might be extra protection and security implemented inside higher tech phone which caused to be not-so-easy to access the device fully, thus causing the problem.

Next, after the "discount" given by my lecturer, I will only need to develop a code in C++ which can calculate the sharpness of an image when it is run (of course, developing the full apps can be done next after this on my own will). To develop the code, a simple C++ software is definitely not enough because the normal library does not contain the "things" we need. Therefore, should we introduce and install some new software/library, which is the Code::Blocks, OpenCV and CMake.

Code::Blocks is free and open source integrated development environment(IDE) which can support various types of compiler such as the visual C++, whereas OpenCV is a library of programming functions mainly aimed at real-time computer vision. CMake is cross-platform free and open-source software for managing the build process of software using a compiler-independent method. It supports directory hierarchies and applications that depend on multiple libraries. 

The difficulties I faced while doing these is during the time to implement and "put in" the openCV into the IDE as it takes a series of process and did really consume some time. During the process, I had encountered a lot of error that tells me the library is unsuccessfully to be brought in the IDE.  I have tried a lot of methods to solve it such as search for the error code, system restoring (because I might have installed the incomplete openCV and it cannot be uninstalled so easily like other software), following different tutorials, referring to friends experienced in all these. Finally, the problem found is that the openCV file downloaded is not extracted properly in the way it should. It might sounds like an easy error, but it really takes me different tutorials, reference and help from experienced friend to identify and spot the problem.

From these, I have learned more about IDE, library, their installation process, precaution step to take care on and possible error to occur. On the moral side, I have learned to be more patience in identifying and solve problem, because dealing with the installation really takes a lot of time and effort, especially when you are sure you have followed the online tutorial fully but somehow error still occur. The online source is a big sea of knowledge, where you can find almost everything in it, when you are frustrated in unable to find the solution online, what you need just maybe some time, patience and help from others in translating the part you do not understand. 


Monday, 11 December 2017

Week 12: The Coding

Heyyy guyssss...we are back on week 12! This week, we gonna begin with the java coding part. And of course, when it comes to coding, a lot of problems and obstacles will come to us, well, seeing things at different prospective, it might be a good thing as the sense of achievement will come to you whenever you managed to solved the error or any obstacles came to you during the progress XD.

Discussing about the math part of the coding, it is believed that we should use "for" loop to deal with the summation (the sharpness function can be view on week 11 post). And also, things are not that easy of course. As the sharpness function will deal with the array of pixel as mentioned during week 11, we need to code the apps so that it will perceive the pixels as an array form and obtain information from there. After that, the multi color pixel should be converted to gray scale pixel, so that it will exhibit intensity between 0 to 255 (black to white) and thus will interpret and process with the contrast measure. The reason we convert the RGB pixel to gray scale pixel is because that RGB pixel would need vector or coordinate system to interpret their intensity, and it will be very complicated and hard to solve for the contrast measure, therefore, gray scale pixel is preferred to be refer for contrast measure no matter which part of the world it is.

However, before proceed to the math coding part, we should first have access to the phone camera. Different methods are used in order to access the camera on our smartphone and the apps are successfully developed in this week, unfortunately, things do not go as expected as there are few problems as listed below:

1) Image captured from the self build camera apps appear to be blurry and pixelated.
- This is due to that the image appeared are in thumbnail, meaning that the blurry image appeared is actually a small image representing the large image. Thus, we should get the full size of image from the camera directly. However, to convert thumbnail to a full size picture, the java codes related to it are implemented on the apps but it seems to be no effect and the same problem still appear! *sigh*

2) The image captured cannot be saved in the phone storage.
- Codes related to access of public storing (built in SD card) within the smartphone are implemented. However, there seems to be lacking of "something" which does not allow the image to enter the storage.

Figure 1: Camera Apps Built. Camerag and CameraHanCheng.
A lot more of camera apps built before this two was made, however, all are uninstalled as they posses the same problem.

Figure 2: Layout of "Camera HanCheng" apps.

Figure 3: Blurry Image Capture


On the process of solving for the two problems mentioned above, different project files, methods, coding are used. The direct related code to "cure" for the problem are also been modified and implemented, unfortunately, things don't seem to work well. 

Another problem faced in week 12 is that the antivirus detect some of the SDK (Software Development Kit) in Android Studio as Malware and quarantine them. This causes the Android Studio to be not able to run the apps either on the emulator or a real smartphone. Upon releasing the quarantined component of Android Studio in the antivirus, it seems that part of the component are gone missing or deleted by the antivirus, thus causing the error of
IllegalArgumentException: Unable to locate adb in Android Studio " to appear whenever we try to run the code in the emulator(or on a real smartphone). This error simply means that there is some missing component in the Android Studio that causes it to be not able to perform at its finest. This can be solved by going to Tools >> Android >> SDK-Manager >> SDK-Tools. Uncheck "Android SDK Platform-Tools" and press Apply to uninstall it, and then, reinstall the SDK again. Based on StackOverFlow, it seems to work for some people, but for me, it does not work that way. Upon unzipping the re-downloaded component, the progress somehow stopped halfway and eventually the error " Installing Android SDK: Stopping ADB" appeared. This means that some component in the zipped file are still missing and are unable to unzip the whole file in order to give the complete SDK for Android Studio to run normally. This problem has caused me to stuck for days finding ways to troubleshoot and configure the problem. In the process, I had uninstalled the whole Android Studio and reinstall again, but somehow the problem still occur. But then, I had finally found the way to solve it, which is by copying adb.exe from the AppData/Local/Android/Android-SDK/Platform-Tools folder and copied it to AppData/Local/Android/SDK/Platform-Tools. This is to give back what the file is missing directly to it's file location and Android Studio seemed to be run normally again after that! 

Week 12 is definitely a week of sorrow. But however, looking things at a brighter side, I did learned a lot more on the Android Studio. Including how to create a new class of Java, have a better and deeper understand on the SDK required to run and support the Android Studio, how to solve for different type of error, meaning of different Java code, arrangement and structure of the code in the way it should, how to direct a file path, meaning of XML code and an overall better understanding and handling of the Android Studio software. 

Besides, on the moral side, I have learned to be more humble, willing to accept other's advice and polite to seek for help from others whenever I feel that situation is not under my control. I also make sure that I'm the one taking initiative to ask for consultation and request to meet up because we should not let other people to come to us as we are the one who are seeking for help, this is the basic respect for the people that are going to help us. We must also always remember to say "Thank You" whenever help or consultation is given as a sign of appreciation to the helper.

Well, that's all for this week! Continue to check on us on week 13 to see what will happen! See ya guys ^^.

Monday, 4 December 2017

Week 11: Understand the math!

Hai guys, it has came to week 11 and things is really getting harder and harder now. But fortunately, I have got the help from the lecturer and senior and hopefully things will work out.

So, before begin to develop the code, first, of course we must know what to be included in the code, and also the rough plan on how to code. Back to week 9 update, it is mentioned that the resolution of an image whether it is brought to be focused enough or not can be determined by the "Sharpness Function". Therefore, week 11 is all about understanding equations! The sharpness function is as follow:

The rough explanation of this equation is that, assuming an image is made up of pixel with threes= sub components, that is, the red, green and blue (RGB) colour component, and the pixels are arranged in the form of array of x and y. The intensity of the RGB will light up differently and individually to give different colour on that particular pixel so that a desired colour is obtained. 

I(x,y) is the intensity value of an image pixel located at (x,y)
Parameter J and K is the height and width of focusing region in the image.

By inserting the sharpness function in the java code, it is believed that the software will detect the peak point when the specimen is brought to be focused and should stop when that particular point is reached. 

Next, on how to connect the Arduino to the Android Studio. This is definitely a hassle project because it involves manual configuration of a lot of stuff. The program flow is as follows

A lot of coding is involved in this process and should be included in week 12 where we start to program the app step by step. Hopefully it's a good and progressive week. Thanks for staying tuned! See ya guys next week!