Wednesday, December 30, 2009
Week 14 Day 3
It was only when I narrow down on 2 suspected variables, tested them and realised the variable just after them was not initialized, I intialized it and it worked fine.
Although I have managed to solve this error, but was upset over the large amount of time spend on discovering just a simple error
Week 14 Day 2
Grabbed an old working copy of the rubic cube, and as I observed, all common methods were the same, nothing was missing and yet there was still the multi-colour problem.
Monday, December 28, 2009
Week 14 Day 1
Although I have failed in 2.4km run, pull up (did only 3 out of 6) and standing board jump (210 out of 216), I am gald that the school is providing a training opportunity for final year students every saturday.
Sunday, December 27, 2009
Week 13 Day 4
Wednesday, December 23, 2009
Week 13 Day 3
Tuesday, December 22, 2009
Week 13 Day 2
The problem was fixed by implementing an if-else to only allow the program to proceed to process image if the variable required was not null.
I have also implemented proper positioning for the windows of the rubic cube application (the rubic cube windows won`t stack on each other now), and also the exit function which will exit the program.
Currently I am working on the save and load functions for the min and max hue, saturation and value for each color, and will complete that by tmr
Monday, December 21, 2009
Week 13 Day 1
Another changes I made that fix the memory leak would be changing one of my method in the loop of a thread, from taking in parameters to not taking in any parameters (just using and modifying the variables globally.
However, I encountered a setback. While I was using the "Leak" performance tool to check for leak again, it crashed around 3 seconds after the application has launched. I take a look at the debugger and saw this :
2009-12-21 16:08:37.962 3DTestApp[4067:7903] *** _NSAutoreleaseNoPool(): Object 0x10ebe0 of class NSCFNumber autoreleased with no pool in place - just leaking
Stack: (0x91edff4f 0x91dec432 0x941ad394 0x94282218 0x94281b32 0x94528023 0x942813ef 0x94280dc6 0x94489ef4 0x944882ab 0x9350e13d 0x9350d57b 0x9350d3e0 0x93529e29 0x93529bce 0x935292a8 0x935290e4 0x5743e2)
3DTestApp(4067,0xa0310720) malloc: *** error for object 0xffffffff: Non-aligned pointer being freed
I did a search and realised that this has got to do with objective C and the solution for Objective C was to use a class called NSAutoreleasePool, which I tried and when implemented it gives lots of syntax errors with the codes, when there were no syntax errors in C++. I have posted this question on various forums, and seeking for answers to it now.
Sunday, December 20, 2009
Week 12 Day 5
I must admit when at first I saw Kevin, Chittanya testing out the CornStarch experiment at the Pantry, I was not surprised of how it jumps as I know the science behind it. But seeing on this day how much fun, joy and knowledge it brings to the children, I must say the experiment is of great value and learning to the children.
The day passed fast and soon the children were at IHPC watching 3D movies and playing games using LightDraw. It was interesting seeing them playing the puzzle games and pinball using lasers, and we were so focused on how they were playing that many of us were telling them where to point.
In the blink of an eye, it was the closing ceremony of the ReachOut 2009 event, and I was standing in the training room as they were giving out presents, one by one, to each of the children. Some of the presents were so big that the children have trouble carrying it, and I was also surprised to learn that these gifts were the gifts the children have previously written on their wish list. This means that if the children request something expensive, IHPC will also buy? WOW how I wish I was them haha.
The end of the day ends with the Children returning home by bus happily. A joyful and meaningful day indeed, hope IHPC will have more of these events in the future.
==============Reflection=============
This week saw me being involved in integrating multi-threading to the rubic cube, and it was my first time doing multi threading for a 3D application. Although there are many errors I have encountered on the way, I have found programming in 3D not as hard as I initially thought.
This week's reach out was the most meaningful event that occurred throughout my internship. The whole IHPC workforce brought joy and gifts for over 60 of the children from Touch Young Arrows, and it was a great experience interacting with the children, seeing how interested they are in science, and their enthusiaism.
Week 12 Day 4
From the Leak Performance tool, there wasn`t any variable names provided, only method names, and I could only narrow down to one of my method, ProcessImage, as the cause of the leak. To ensure that this information was correct, I commented out the method that is suspected to produce memory leaks, and indeed, the Leak Performance tool shows the memory being stablized thereafter.
Wednesday, December 16, 2009
Week 12 Day 3
After I run the application, I realised that the cube is still very slow in its turining.
After some trying, I swapped the processing of the rubic cube with the position of the codes that copy the captured image from the camera to another variable, but realised it is still the same.
I then decided to try putting the reading of the image from the camera and the processing of the image into the one separate thread, letting the main thread do the 3D drawing. This fixed the problem and now the cube draws at an acceptable speed.
However, I am now having memory leaks in the application. I used a tool called Leak and realised that during the runtime, the program can take up to 1.5gb and still growing amount of ram before it crashed. Could not find the loophole in the code today, and I will attempt to work on this tomorrow.
Tuesday, December 15, 2009
Week 12 Day 2
After seeking guidance from Ming Hong, I realised that I could actually put the processing and updating of the camera frames in the display method that would be run by the glut_main loop, and leave the main method to execute the glut_main loop. I tried implementing it however got a crash. Will look into this error and fix it tomorrow.
Monday, December 14, 2009
Week 12 Day 1
I have also discovered that why using the negotiation method I implemented on Friday, it will result in the camera waiting for the program to be ready and vice versa, hence defeating the purpose of multi-threading. Hence, I will be trying out a method whereby the program will instead store a copy of the fram being captured to another variable, and the processing of colours will then use that variable for controling the rubic cube.
Friday, December 11, 2009
Week 11 Day 5
Today I switch my programming task with my partner, and currently I will be working on the multi threading feature of the rubic cube instead. One interesting thing I found out was that C++ does not allow reading from camera in threads other than the main thread. As such, what I am implementing now would be to place the reading of the camera frame in a infinite loop (till the user press 'q' for quit) in the main method, and it is working successfully.
In order for the reading of the camera to a frame to work successfully in a loop with other threads sharing the frame, I have to implement variables to ensure that when the frame is captured, the other threads will read the frame before allowing the frame to be replaced with a new frame.
Today was also the day where Kevin would be leaving Singapore and returning on January. Manage to see Kevin for the last time this year at 3pm, but didn`t manage to say much. If you are reading this, I would wish you to say thanks for your guidance and advice all along, it is because of you that our internship was a great and fun one ! Haha, and I will ensure when you come back to January, my presentation will be 200 times better than how I presented previously.
==========Reflection of the week ===============
This week seems to pass quickly as most of the time was spend on programming. However, I have learned and implemented turning of the rubic cubes, gained knowledge of problems when multi threading is used for reading a frame from camera, and also on my weakness and strengths in presentations.
Probably I have realised in many things I do, I still do the same old mistakes, and that was due to lack of practice. Certainly I believe I can improve on these, and I will be attempting from now on to change these
Thursday, December 10, 2009
Week 11 Day 4
As such, I now have to limit the user to only move a particular surface in only a partricular direction.
Howeer, despite most of the rotation working smoothly now, I found out that there is a serious problem with the bottom and top layer right and left rotation, which caused some cubes to go missing suddenly.
Today I have also fixed the insufficient memory crash by moving all images declaration to the outside of the draw rubic method, and into the global declaration part
Wednesday, December 9, 2009
Week 11 Day 3
- Talk slower
- Don`t beat around the bush
- Ensure content is relevant
- Ensure content is correct
- Skip through forgotten items, not pause at them
While for the speed wise, I still remember the embarrasing moment when our school was having Japanese Exchange (where students from Japan came to visit TP) and I was presenting a speech. I was so nervous and anxious that I talked like a bullet train, and my Course Manager, who happen to be seating at the first row have to signal to me to slow down.
The rest of the day was spend on continuing the improvements for the rubic cube application. Currently I realised that if the cube is rotated halfway in a specific direction, and another rotation is applied to it, some cubes will go missing or the whole plane of that cube will split up.
To prevent this, I am writing codes to make the cube turn to a 90 degree position before another rotation of another direction will be taking place
Tuesday, December 8, 2009
Week 11 Day 2
With regards to the turning of the cube, initially I programmed it to rotate a full 90 degrees so long as it detects a finger moving downwards. However, it could not function well as the limit of the distance for the cube to start rotating does not seems to work smoothly with my experiement.
After some advice, I decided to programme the rubic cube to turn in accordance of how much distance the finger moves across that particular plane or surface, and it worked well.
The last improvements of the day was snapping the rubic cube planes to a full 90 degrees in the event when the user does not move the distance required to do a complete 90 degrees rotation.
I encountered some calculations error where the program shows that the rotation is a complete 90 degrees, but in actual fact the rubic cube planes are somewhat not a complete turn.
After much advice, I realised this was due to modulus with negative numbers, which produces unexpected numbers. It now works fine.
Monday, December 7, 2009
Week 11 Day 1
However, I realised this caused severe lagness in the turning of the cube. After advice from my supervisor, I realised that it was due to the frame rate being set to 1000 max. I changed it to 25 and the laginess is reduced, but not as perfect.
After much consideration, I came up with 2 ideas. One was to call the camera detection method in a different thread, and the other was to call the camera detection method only every half the maximum frame.
I tried the 2nd method, and the cube now draws quite smoothly. I then proceed to draw a small rectangle to indicate the position of the detected fingers. However, as much as I try, I still did not mnage to get the application to draw the rectangle out. Will continue to check this on tomorrow.
Sunday, December 6, 2009
Week 10 Day 5
Besides that, for a rotation to be perfect, rounding off errors need to be prevented, or else some cubes on certain parts of the rubic cube may suddenly go missing. This is due to the fact that if there are rounding off errors, one cube may touch the other cube upon rotation, and this may cause the cube to intersect with another cube, hence the cube may only appear partially or even disappear completely.
I will be starting on integrating this rubic cube application into our initial holotouch application next week, and hopefully when this is done, we will have a presentable application.
===========Reflection==================
I have spend the entire of this week into coding with OpenGL. Similar to my coding experience of asp.net, where we learn the drawbacks and advantages of these technologies only while we are developing for it, I have also learned the pros and cons of OpenGL programming, and have completed a rubic cube with the help of MingHong(supervisor).
Indeed learning something new takes time, but it helps to open up another dimension. For me, I have been developing web applications for mostly simplifying paperwork, and OpenGL has allowed me to also program visual applications.
Wednesday, December 2, 2009
Week 10 Day 4
The formula was an equation of cosine and sine, which although seems complicated, but he assued us it will not be as hard.
As such, I am currently finishing up the last part of storing these points to prepare for the rotation.
Week 10 Day 2
Will post any updates when its done
Week 10 Day 1
Continuing from last week, I implemented translation to the entire rubic cube, and it worked well.
Currently I will be continuing on the storing of all points into a vector containing a struct,which contains more variables and structs.
Week 9 Day 5
This caused the cube to rotate around the top left point instead. I tried to change the x,y and z of the rotation and also putting the codes to draw the uppermost middle and centre cube first, but it doesn`t help in anyway.
Finally, I asked Ming Hong and realized the problem was due to the cube being drawn below the origin, which was not shown in the 3d view. I could do 2 things :
-Change the coordinates for all the cubes so that the uppermost middle and centre cube is at the origin (0,0,0)
-Use glTranslate to move the 3 cubesets that I have created to the appropriate position.
I am currently working on the second solution, and hopefully it solves the issue.
=================Reflection=============
Time passes fast, and today counts the last day of Week 9 that I have worked in IHPC. This week saw me coding on OpenGL for the first time in my life. I have now more understanding of how software like games and CAD draws 3D images on the screen and what OpenGL can do.
It has been a week of coding in C++ on OpenGL, which is new to me, but definitely very useful for the development of the HoloTouch project. I have now thought of various projects that I can make use of OpenGL with, and I am planning to code them after my SIP
Week 9 Day 4
Upon coding for rotation in the other direction, I realise that due to the way the cubes were drawn in my codes, there will be a bit of problem with the rotation of the other side, unless I were to redraw the cube upon every rotation.
As such, I have created a struct that stores a vector that stores yet another struct that stores each details of the individual points declared in my code.
Declaring the struct and vector was easy, but not the storing of the points into it.
Week 9 Day 3
Increasing the color for each of the cubes doesn`t seems to work, and currently my approach was to space it out with a little bit gap again so this does not occur.
Spend the rest of the day thinking and analyzing on how to rotate the cube (each layers) vertically and horizontally together, and currently still in the process of looking for an answer