Sunday, November 23, 2014

Practical Python and OpenCV: a review (part 2)

In part 1, I mentioned that I intended to review the "Case Studies" of the bundle I got from Practical Python and OpenCV  and that I would discuss using the included Ubuntu VirtualBox later.  However, after finishing the blog post on Part 1, I started looking at the "Case Studies" and encountered some "new" problems using the VirtualBox that I will mention near the end of this post.  So, I decided to forego using it altogether and install OpenCV directly.

Note: If you have experience using VirtualBoxes, then it might perhaps be useful to get the premium bundle that includes them; for me it was not.  Including a Ubuntu VirtualBox already set up with all the dependencies and the code samples from the two books is a very good idea and one  that may work very well for some people.

If you need to use VirtualBoxes on Windows for other reasons, perhaps you will find the following useful.

Setting up the VirtualBox

Running Windows 8.1, I encountered an error about vt-x not being enabled.   My OS is in French and googling French error messages is ... hopeless.  So, I used my best guess as to what were the relevant English pages.

From http://superuser.com/questions/785672/linux-64bit-on-virtual-box-with-window-7-profession-64-bit  I understood that I needed to access the BIOS to change the settings so that I could enable virtualization mode.

Unfortunately, I (no longer) was seeing an option to access the bios at boot time.     There are *many* messages about how to re-enable bios access at boot time, most of which simply did not work for me.  The simpler method I found to do so was following (at least initially) the explanation given at http://www.7tutorials.com/how-boot-uefi-bios-any-windows-81-tablet-or-device.

(However, I found out afterwards, that the bios not being accessible is possibly/likely simply because I had a fast startup option checked in power settings.)

Once I got access to the bios, I changed my settings to enable virtualization; there were two such settings ... I enabled them both, not knowing which one was relevant.  I do not recall exactly which settings (I've done this one month ago and did not take notes of that step)... but navigating through the options, it was very easy to identify them.

This made it possible to start the virtual box,  but when I tried for the first few times, I had to use the option to run as Administrator for this to work. 

The first time I tried to start the image (as an administrator), it got stuck at 20%.  I killed the process.  (I might have repeated this twice.)   Eventually, it started just fine and I got to the same stage as demonstrated in the demonstration video included with the bundle.   Started the terminal - the file structure is slightly different from what what is shown in the video but easy enough to figure out.

Using the VirtualBox

I've used the VirtualBox a few times since setting it up.  For some reason, it runs just fine as a normal user, without needing to use the option run as an Administrator anymore.  

My 50+ years old eyes not being as good as they once were, I found it easier to read the ebook on my regular computer while running the programs inside the VirtualBox.  Running the included programs, and doing some small modifications was easy to do and made me appreciate the possibility of using VirtualBoxes as a good way to either learn to use another OS or simply use a "package" already set up without having to worry about downloading and installing anything else. 

As I set up to start the "Case Studies" samples, I thought it would be a good opportunity to do my own examples.  And this is where I ran into another problem - which may very well be due to my lack of experience with Virtual Boxes.

I wanted to use my own images.  However, I did not manage to find a way to set things up so that I could see a folder on my own computer.  There is an option to take control of a USB device ... but, while activating the USB device on the VirtualBox was clearly deactivating it under Windows (and deactivating it was enabling it again on Windows indicating that something was done correctly), I simply was not able to figure out how to see any files on the usb key from the Ubuntu VirtualBox.  (Problem between keyboard and chair perhaps?)

I did find a workaround: starting Firefox on the Ubuntu VirtualBox, I logged in my Google account and got access to my Google Drive.  I used it to transfer one image, ran a quick program to modify it using OpenCV.  To save the resulting image (and/or modified script) onto my Windows computer, I would have had to copy the files to my Google Drive ...

However, as I thought of the experiments I wanted to do, I decided that this "back-and-forth" copying (and lack of my usual environment and editor) was not a very efficient nor very pleasant way to do things.

So, I gave up on using the VirtualBox, used Anaconda to install Python 2.7, Numpy, Matplotlib (and many other packages not required for OpenCV), installed OpenCV (3.0 Beta), ran a quick test using the first program included with Practical Python and OpenCV ... (loading, viewing and saving an image)  which just worked.

Take away

If you have some experience running VirtualBoxes successfully, including being able to copy easily files between the VirtualBox and your regular OS, then you are in a better position than I am to figure out if getting the premium bundle that includes a VirtualBox might be worth your while.

If you have no experience using and setting up VirtualBoxes, unless you wanted to use this opportunity to learn about them, my advice would be to not consider this option.

Now that I have all the required tools (OpenCV, Numpy, Matplotlib, ...) already installed on my computer, I look forward to spending some time exploring the various Case Studies.

---
My evaluation so far:  Getting the "Practical Python and OpenCV" ebook with code and image samples was definitely worth it for me.   Getting the Ubuntu VirtualBox and setting it up was ... a learning experience, but not one that I would recommend as being very useful for people with my own level of expertise or lack thereof.

My evaluation of the "Case Studies" will likely take a while to appear - after all, it took me a month between purchasing the Premium bundle and writing the first two blog post.  (Going through the first book could easily be done in one day.)  

I do intend to do some exploration with my own images and I plan to include them with my next review.

No comments: