Monday, February 22, 2016

Create Video from Still Images using iMovie 10.0.5

I wanted to create an animation of tailgating vs smooth cruising driving from still images. After search around, the free alternative for a Mac user like me is iMovie. I can't find much tutorial for the new iMovie in Mavericks, so I thought I should put one up here.

The most important thing here is to prepare your still images. I miss Paint in Windows system, but the next best option I have for Mac is Preview. Check out here how I prepare my still images.

Steps:

1. Lauch iMovie
So many buttons. You can see on the left panel, All Events and All Projects. It was quite confusing for me at first. What do I want to create here? A movie? project? or event? 'Events' are kinda like the main folder/categories for the movies you created. Projects are all the stuff you have created in iMovie, basically your movies. Feel free to correct me if I'm wrong =)

Eg: I went to Taiwan last May 2015. So I may create an event named 201505-Taiwan. Under the event 201505-Taiwan, I may have create movies such as: 150513-Taipei101.mp4, 150514-TaipeiZ00.mp4, 150515-RaoHeNightMarket.mp4.

In this figure below, I have an event called 160219-FKJ, I will saved all movies created for my research purpose under this event.
iMovie 10.0.5

Step 2: Import images
Once you have created/choose the event, then we can import the still images for our movie. Click on the button Import at the top and navigate to your images. If you have lots of images, I would suggest to name your files accordingly. I have certain naming conventions for all the 49 images below.
Import still images


Step 3: Create movie
Now we can create our movie. Simply click on the '+' button at the top. I usually choose no theme for a simple academic animation. 

Create movie

Step 4: Adding images to the movie
You can drag the imported images to the timeline below. But make sure you know which image is which. When you selected an image in the timeline, the info of the selected image will show on the right panel. If you can't see this, click on 'adjust' --> 'circled-i'. In my case, I will drag the images accordingly(160222-tfsWaves-1 to 160222-tfsWaves-49)

Adding images to movie

Step 5: Cropping style
Once you have selected all the images, Select-All (Ctrl-A) to set the size of your images. By default the cropping style is set to 'Ken Burns'. I'm just gonna change all to 'Fit'. You can play around to see what style fits your movie
Cropping style

Step 6: Setting frame duration 
To set your frame duration, Select-All (Ctrl-A), click on the circled-i on top. You can set as fast as 0.3 secs per image( that's the lowest you can go). I'm just gonna set mine 0.5.

Setting frame duration

Step 7: Test movie
You can start playing the movie from start or any sections you want. At the timeline, simply bring the vertical lines to the position you want and hit Spacebar (to start or pause).

Step 8: Save movie
Once you are satisfied, click on the 'share' button. I'm just gonna choose to save it as a file on my desktop.
Share/save movie.
 Add description and select movie size

That's it. Voila! You can use the same steps for adding/combining videos too. Of course there are many other things you can add in iMovie, but once you get familiar with the interface, the rest pretty straight forward. It wasn't that hard actually, but it put me off for few years from using it. 

I hope this helps and feel free to comment below. Thanks.

Some remarks:
Some other basic features you might need are at the lower left panel. 

  • Transitions - Some nice effect for images/videos transitions
  • Titles - Titles
I never try what's iTunes and GarageBand for so I'll just leave it.

I used HandBrake to compress video size, and QuickTimePlayer to fix upside down video.


Wednesday, January 6, 2016

Create Simple GUI in Matlab

It's always easier if you can put your Matlab coding in GUI. Especially if you have lot of functions, you can use different push-buttons for each functions. This post will guide you to create a simple GUI, consists of your program title, push-button for function, axes to display your simulation/results.

Steps:

1. In Matlab Command Window
>> guide
choose 'Blank  GUI (default)
2. A window will pop-out, you can design your GUI anyway you like. I usually keep it simple. There are 3 basic things you need for a basic GUI:

  • Static text - optional but I like to have title for all my programs (double-click to access the properties)
  • Push button - I used 2 push buttons, for 'Run' and 'Stop' (double-click to access the properties)
  • Axes - this is where your simulation shown. You can set your Axes to have toolbar
Some note on Axes: I usually have toolbar for Axes, so I can navigate to each pixels and get their information, or zoom in and out. 
To customise your Axes toolbar:
  1. Single left-click on Axes 
  2. Click 'Tools' on the menu
  3. Select 'Toolbar Editor'
  4. Drag the following to the top: Pan, zoom in, zoom out, data cursor (you can customise to your liking)
Building Matlab simple GUI

3. Rearrange and resize your window GUI accordingly. Save your GUI.

4. Once you save your gui (.fig file) an m-file will be automatically generated (the .fig and .m file will have the same name)

5. Open the GUI's m-file, and copy-paste each m-files function to each designated buttons. For instance, the 'Run' button is  under function pushbutton1_callback(hObject, eventdata, handles). I can put all my code under this button.

The 'Stop' button is under function pushbutton2_Callback(hObject, eventdata, handles). I already set my 'Run' button to execute a while loop (eg: while stop==0), so I can set my 'Stop' button as following.

push-button 'Stop'

Basic GUI

Friday, December 4, 2015

Adding xlwrite to Matlab Static Path

Disclaimer: I'm not sure if the following steps going to mess up your system. This is what works for me, atm. Use at your own risk.

In my earlier post, I added the xlwrite and its needed 6 jar files to Matlab dynamic path. However every time I restart Matlab, I have have to re-do this setting again. I hate going back to my own post and checking out the steps, spending another 1 min to set up the system to use xlwrite. I know 1 min is nothing, but I like things automated. To go about this, add the jar files to Matlab static path. Check here for more about Static Path vs Dynamic Path.

I look everywhere on how to add jar files to static path. I didn't find any clear instructions on how to edit the classpath.txt, anyway this is what works for me.

Steps:

1. In Matlab command window:
>> edit classpath.txt
2. M-file will open. MATLAB reads the static class path only at startup. You can see these are all the files loaded at startup. Eg:
$matlabroot/java/jar/zh_CN/web_connectivity_res.jar

3. We want Matlab to load our desired jar files at startup too. So put your jar files (poi_library) in matlabroot/java/jar/. Where on earth is this place? I'm using Mac, so that place is
Applications> Matlab>right-click>Show Package Contents>Java>jar

matlabroot/java/jar

4. Back to Matlab, append the following at classpath.txt
$matlabroot/java/jar/poi_library/poi-3.8-20120326.jar
$matlabroot/java/jar/poi_library/poi-ooxml-3.8-20120326.jar
$matlabroot/java/jar/poi_library/poi-ooxml-schemas-3.8-20120326.jar
$matlabroot/java/jar/poi_library/xmlbeans-2.3.0.jar
$matlabroot/java/jar/poi_library/dom4j-1.6.1.jar
$matlabroot/java/jar/poi_library/stax-api-1.0.1.jar

Append classpath.txt
 5. Save and restart Matlab.


Note: If you have warning regarding 'undefined xlwrite function', means you haven't set the path to xlwrite yet. To set the path:


Tuesday, December 1, 2015

Thai Color Run - Happiest Run on The Planet

I don't usually register for such short run, 3 km or 5 km, but I made an exception for The Color Run. According to their website it is a paint race, hosting more than 300 events in 50+ countries in 2014. Coincidentally, Thai Color Run was just around the corner during my trip to Bangkok. I was already late for the normal fee, but registered anyway THB 900. Sob sob.. quite expensive for such a short run. Never mind just for the experience, running in a foreign country.

But my feet was quite sore after 3 days wandering in Hua Hin, the southern Thailand. My run was on 1st November 2015. Now I thank God for it was just for a short run. 

I can't really remember the order of the color threw at me, I think start with purple, orange,  yellow, blue, green.

The run is a bit different than what I used to. This is more like fun run, you can just walk or crawl if you wish. The running is by section, I guess maybe the route in Jatujak not allow all to run to the finish line together. During the run you have to stop and wait at certain sections so the runner before you can finish the route before you run that route. I mean the sections were overlap. The park wasn't close for the color run purpose, you can see some others jog and cycling in the park. 

Anyway, let's just see the pics post, shall we?



Before start: running by section, waiting in my section.
KM 2
Waiting ...
Can just walk the 5 KM
KM 3
KM 5
Yeay.. finishing line
Color party afterwards



Project 33 - Purging My Closet

I always want to live with minimum things/ no attachment to whatsoever and to be able to just pull one luggage out from the door if I have to. Such freedom, not tying to anything and buried with everything. If it was something really darn expensive that I can sell then it would be good, but mostly are those unnecessary and sentimental value items.

One small step at a time. Just like most girls/women, I have more clothes than the number of days in a year. Yesterday I was shopping and saw H&M taking clothes donation for recycling purpose, in ex-change for 15% voucher. I'm not a big fan of H&M but this is a good chance to let go of clothes and putting it to good use.

Ok, just 4 links to get me started...

The Project 333
Into Mind
Capsule Wardrobe 101
Infographic - A Guide to Organising Your Wardrobe


Ganbatte ne!

Monday, November 30, 2015

Warning: Could not start Excel server for export - Use xlwrite

Update 04/12/15 - The following steps will add xlwrite and its jar files to Matlab dynamic path. However, you will have to redo the steps again every time you restart Matlab. To go about this, add the jar files to Matlab static path. Check here.

I can use xlsread in Matlab for Mac successfully, however using xlswrite gives me the following error:


After some googling and trying on csvwrite, I find another code on Mathworks. I strongly suggest those out there that hesitate to use csvwrite to give this a try.

This pic-post will walk you through on how to use xlwrite.

Step 1:
1. Download xlwrite .

2. Unzip it and put all the files in your designated folder. (I'm a digital-organised freak).

Content of your downloaded files.

3. We want to know the path to all this POI files. On Mac, click cmd+i.
cmd+i to get the information of the files


4. In Matlab command windows, use javaaddpath to add all the needed jar files.

Or you can add 'xlwrite' to Matlab path. 




That's all. You can see 'test_xlwrite.xlsx' is created in your current folder.

See file xlwrite or go to <url> for full license details.

Tuesday, November 17, 2015

Windows 7 Startup Looping Infinitely

*** Feel free to jump to the end of this page for the potential solution ***

I have been neglecting to help anyone to reformat their laptop. Installing Windows used to be an easy and straight forward job. Ten years ago you probably need 4 parts: Get a working Windows installer, Format the desire partition, re-install windows, install utility drivers (come along with your laptop in a CD)

But now, you no longer get the Utility CD when everything just a click away. Maybe few clicks away...

Back then, all laptops more or less the same. What made it difference are the specs, what's the CPU used, RAM and hard disk capacity, graphic card etc. But today, with product differentiation, by making the product unique and attractive to consumers, a laptop no longer just about its hardware specification and operating system. 

I only have one windows laptop which is by Acer. I'm pretty happy with. I got it slightly cheaper than the retail price because it was open OS. Meaning the shop that sold it to me installed a non-genuine Windows for me to get started. I don't mind. Acer's laptop in 2009 have another feature called Empowerment Technology (if I'm not mistaken hehe). However that function on my keyboard never seems to response every time I press on it. And yeah 7 years later I still have no idea what I missed from not having this feature on my Acer. 

On the contrary, that could be what I gain. I lost count on how many times I formatted this Acer laptop and I never really encountered any weird problems. It usually took me maximum of 1 hour to format and reinstall, get it up and running like new. 

But hell, yesterday I spent more than 10 hours just to re-install Windows 7 on an Asus laptop. 7 years ago, my Acer was differentiated by one feature, which I happy not to have. But Asus today ... wow. All I can is you should leave formatting a laptop to the professional technician. Where they have all the necessary utility drivers and  access to fast internet in case they need to look for one. 

Ok, so when I almost finish installing Windows 7 on Asus, as usual I get the message that the system will restart several times to complete the installation. And I was like.. Ok.. whatever, just get it done. 

The system was not just restart like 5, 6 or 7 times, but I lost count. I checked my timer, this is unusual. It has been more than an hour and still not done? I was reinstalling about 3 or 4 times, trying both 32 and 64 bit. Then I know I fall into the startup loop. What I can observe: boot up > "windows is loading files" > windows logo > Asus background > boot up

I was googling around and found some commands to try, but to no avail in my case. 

Anyway you may check out this link first, it may work for you, but if NOT, try the steps below :
  1. Boot up using your windows installer
  2. Click repair/ system recovery options
  3. Choose command prompt (If your path is X:\Sources,set it to C, just type C:)
  4. Type the following command
bootrec /fixmbr 
bootrec/fixboot 


It's true everything is just one click away, but the RIGHT solution could be 1000 clicks away.