Introduction About Site Map

XML
RSS 2 Feed RSS 2 Feed
Navigation

Main Page | Blog Index

Archive for the ‘Programming’ Category

OpenCV, Android, and Hardware Limitations

Car navigation using computer vision algorithms/programs (as opposed to GPS/maps) is scarcely explored in the form of mobile applications. With many built-in cameras and increasing processing power/RAM it would be desirable to exploit — to the extent possible — whatever general-purpose devices have to offer while idle; single-purpose appliances like TomTom make less business sense nowadays and development frameworks for mobile platforms have become versatile enough to empower third-party developers. Based on conversations with colleagues, OpenCV and its many plugins should be somehow available for Android as well, albeit it may require some hacking and adaptation to the hardware at hand (high-end ARM for the most part).

If the goal is to make vehicles with cameras mounted onto them interpret a scene like humans do, then analysis of video sequences on mobile hardware (efficient applications) ought to be explored, with special emphasis on performance. C++ has little memory footprint and high efficiency. Contemporarily, resolution at a high capture rate is satisfactory enough for the task, but it is unclear whether a good algorithm that segments and tracks a scenes can keep up. A GPU-like processing power is available on some phones, but not all (drivers for non-x86 architectures are poor or scarce, too). MobileEye offers peripheral and assistive hardware for this reason, recognising the known caveats.Vuforia does augmented reality for mobile platforms and a company called ThirdSight also makes mobile applications with computer vision methodologies. Not so long ago (April 2010) it was reported that “development of new automobile safety features and military applications [...] could save lives.” The hardware is not specified in the report. To quote, “Snyder and his co-authors have written a program that uses algorithms to sort visual data and make decisions related to finding the lanes of a road, detecting how those lanes change as a car is moving, and controlling the car to stay in the correct lane.”

While purely automatic driving is currently verboten, computer-aided driving is legal and forms a growing trend. It need not involve any mechanics either, as it’s most about message-passing to a human (HCI).

Making Spirals in Octave/MATLAB

Occasionally, in numerical programming, one may wish to plot or instantiate a grid of a circular (or spiral) nature. Here are some code samples for those trying to achieve it. The following sets some values of interest:

lines=10
degrees=180

Now, let us generate some linear, equally-spaced points:

t_map = linspace(0,lines*pi*2,lines*degrees*2);

What we have here is the 2 for 360 degrees, which may depend on what one tries to achieve. For the more complex case shown later, this will be essential. Now, let’s do the sine/cosine magic:

x_map = t_map.*cos(t_map);
y_map = t_map.*sin(t_map);

This can be plotted with plot(x_map, y_map), but let’s do something more interesting by assigning colour to the sample points and then plotting them as dense dots. The following would work:

flat=zeros(1000,1000);
  for ll=(size(x_map,2)/2):-1:1
    flat(floor(x_map(ll*2))'+500,floor(y_map(ll*2))'+500)=1
  end
imshow(flat)

The values here are rather arbitrary and can be used for demonstrative purposes. The problem itself seems to be commonly recurring, thus the need for a blog post. Different colours can be assigned to sample points, which achieves something like the following:

Spiral examples

PageRank 7

Finally, for the first time ever, I have gotten a site whose front page is PageRank 7. That would be Techrights. I didn’t see it coming and this is part of a group effort, so it’s a victory for many of us who worked on it for years. I cannot think of another Linux-oriented site which has PageRank 7 or higher. It’s an important milestone for sure, even if it’s mostly symbolic.

Today was generally a great day and I met an old friend who is now a boxer. Did some programming, ran successful experiments, and some of the changes are compiled without an issue, removing the zlib dependency from Cyrus. Now is the time to have these tested and the plan is to use the existing interfaces with some test data and detect mis-correspondence in CRC polynomials. Tomorrow, heavy blogging will resume and maybe a trip to London will wait until Monday.

Outperforming PCA, Revisiting MATLAB

Post-denoising small

I currently work on a very fascinating project which deals with 3-D face recognition, as already stated back in January. Progress has been noticeable recently (easier to get coding done when the Internet is mostly unavailable due to Bad Telecom [1, 2, 3]) and the accompanying text is now about 50 pages long.

A few observations about MATLAB: the programming framework has not really developed much since 2003. It’s either quite stagnant or improved only in unseen places. I did not forget how to develop a GUI environment very rapidly.

A few observations about PCA: the method is a little antiquated and it can probably be outperformed by more problem-specific implementations of algorithms we explore.

A few observations about Bad Telecom (or Bastards Telecom, although some people view the word bastard as too strong): they only ever serve the customer properly if he/she becomes a threat to the reputation of the business. It is sad that customers must be seen as a risk before they can actually get progress made.

Fedora, Importance of GNU/Linux Competition, and Technological Freedom

FEDORA 11 is a fine distribution of GNU/Linux, but my session got stuck (frozen) today. Generally, scheduling on the desktop in this out-of-date operating system is somewhat deficient. Windows sometimes do not respond for a period of several seconds. The bug where a text selection cursor is made permanently visible and allows no real interaction with any applications kicked in… againtoday. It happens quite rarely with other distributions and there’s an escape route out of it, e.g. if the terminate signal can be sent to the application causing it, assuming it can be identified. But not this time though. Bearing in mind that it’s not the very latest version of Fedora and having used the fourteenth release since it was made available (even installed it for others), it does seem fair to say that for a smooth experience on the desktop, one is still better off going with the Debian family. Mandriva (predominantly but not strictly RPM-based) has been very good too, probably a lot better than Fedora.

The problems with Fedora are not really caused by adherence to freedom. Some creases and bugs, however, might not be addressed early enough because Fedora’s adherence to freedom (not strict adherence, but better than Ubuntu’s for example) limits the extent of its userbase, which in turn reduces the incentive Red Hat has to concentrate on the desktop side of things.

I have been working with Fedora 11 since last Friday (just waiting for my home computers to get back online with the new line activated) and as much as I try to love Fedora, I cannot help feeling that Kubuntu and Ubuntu have been giving me less hassle. Deep inside I wanted to declare that Fedora was better, but the experiences simply suggest that any such claim would be wishful thinking, even deceptive. The problem is that Canonical was made quite arrogant (hello Hubris!), which harms Ubuntu on technical and communal grounds alike. Canonical could use more competition.

It may be true that Linux in the mainstream is all about Android, Google, Ubuntu, mainframes, and Red Hat Enterprise Linux these days. That’s fine. As long as Fedora uses and reuses the same pertinent packages, there is no risk of Fedora truly falling behind. The wonder of Free software is, as long as one is allowed to copy the competition or branch out of it, unfair advantage is harder to gain. Canonical and Google have both attempted to produce “added value” (or enhancement) which is hard to emulate, replicate, or even get involved in. They are using some very vendor-specific code, which changes the balance of control not just with copyright assignment. It’s not progress and it is usually counter-productive.

Next week I will resume GNU/Linux advocacy and do a lot less programming (below is a new screenshot of the application I have been developing, but it’s unfortunate and regrettable that the code depends on a proprietary framework) and there is a lot of thinking to be done regarding strategy. Generally speaking, the world’s population loses control over technology at a very rapid pace* and software freedom is no longer the only freedom worth pursuing by a developer with passion for humanism. The head of the Free Software Foundation (FSF) has just stepped down and it is hard to blame him; maybe he too reached similar dilemmas and came to realisations that software freedom is not enough. Collaboration too is crucial (GPL encourages it), not to mention education in general.

Expressions GUI
____
* I spent half an hour this morning chatting with a lady in her 70s. She too — not too surprisingly — feels as though mobile phones are a burden rather than a blessing. In general, she is also concerned about today’s society which lacks face-to-face interaction and intimidates her generation that’s not at all accustomed to a technological control grid. Free/libre software is being used a lot in this context (primarily for companies to bring their user-hostile proprietary layer to market immediately), not as much is being produced though. If technology is not built to provide the user some more control, then it usually tries to control the user. But people are not made sufficiently aware of it, unless the FSF speaks out, as it recently did against Android.

Developing With Fedora 11

GMDS/PCA

FEDORA 14 was a bit of a mixed bag, but it was definitely an improvement compared to previous versions. I’ve used it since it was released (and blogged quite a lot about it). At the moment I use an older version:

bash-4.0$ uname -a
Linux [XXXXX] 2.6.30.10-105.2.23.fc11.i686.PAE #1 SMP
Thu Feb 11 07:05:37 UTC 2010 i686 i686 i386 GNU/Linux

Not to worry, it’s up to date and it runs the latest KDE. The general impression has been positive, having worked on this operating system for the past week or so (still awaiting my Ethernet’s return, so working from a lab, not via SSH). A few remarks about the weak spots:

  • X (org/server) blows up under particular circumstances where a newer version of X might be expected. If an attempt is made to invoke it from a remote host (SSH with X forwarding), the whole of Fedora blows up and the session must be restarted. If run locally, the same type of X issue simply raises a hardware-based exception and produces a major warning, then gives the option to gracefully shut down the affected program. It’s not good, but it’s definitely better than the former scenario, which is reproducible by the way.
  • Dual-screen handling is fantastic. It is still a plug-and-play experience, even with Fedora 11 in place.
  • There are far too many visual artefacts and drawing bugs (direct rendering is lacking). Again, this may just be the fault of old X and nothing whatsoever to do with the drivers of this GPU (Fedora seems to favour free drivers).

Aside from X rants, this platform is fantastic for development. Everything has worked well so far, except Firefox with occasional crashes (occurring at least once a day).

Is Fedora ready to become the most widespread GNU/Linux desktop? Probably not yet. But for development? Sure, why not? Fedora 14 is more mature, but that too has some wrinkles which I covered here before.

By the way, the screenshot at the top (click to zoom) shows the application I’ve been developing recently. More details will be published shortly as blogging distracts from persistent coding, and vice versa.

Cardiomat Version 1.0 is Released

TODAY I AM releasing the final code from my current project. The following is the accompanying README file:


Homepage: http://schestowitz.com/Research/Cardiac/Cardiomat
Index of related documents: http://schestowitz.com/Research/Progress/2010-2011.htm

INTRODUCTION

Cardiomat is the name given to an Octave/MATLAB program whose intended use is heart tracking, with various different bits that help probe cardiac structure and perform basic measurements.

FILES

Contained in the package are the following M-files and sub-directories:

./Experiments
./Experiments/fiesta_simulation-old-experiments.m
./create_synthetic_set.m
./GUI
./GUI/cardiomat.png
./GUI/splash.m
./GUI/splash.fig
./GUI/get_parameters_from_user.m
./GUI/getoptionsgui.m
./GUI/cardiomat-title.jpg
./GUI/cardiomat.m
./GUI/cardiomat.jpg
./getdicomimages.m
./loadtaggedsequence.m
./README (this file)
./Imported
./Imported/findit
./Imported/findit/findit.m
./Imported/arrow
./Imported/arrow/arrow.m
./Imported/gradient
./Imported/gradient/gaussgradient.zip
./Imported/gradient/gaussgradient
./Imported/gradient/gaussgradient/gaussgradient.m
./Imported/gradient/gaussgradient/README.txt.txt
./Imported/gradient/gaussgradient/testgaussgradient.m
./Hybrid
./Hybrid/cardsim_frame_shortaxis.m
./Hybrid/shuffle_transform.m
./fiesta_simulation.m

In addition, the program depends on at least one function from biosig4octmat-2.50, whose homepage is located at http://biosig.sourceforge.net. That function helps find the centre and the radius of a best fit circle/sphere for a group of points.

The directory named “Hybrid” contains functions that were written jointly and “Imported” contains functions which were brought from the outside. The core functions in the package are GPLv3-licensed and the rest are most likely to be BSD-licensed (check the sources to verify). Some of the imported functions may work only in MATLAB and not in GNU Octave, which is a free/libre substitute for MATLAB that lacks some graphical features for the most part.

HOW TO RUN THE PROGRAM

The program was written to be compatible with both Octave and MATLAB. There are some features in it that may require a UNIX/Linux system (e.g. animated videos) and some that may require MATLAB. Additionally, in order to reduce dependency on MATLAB’s GUI utilities, the program can be run in GUI and CLI modes separately, with only the use of figures being the exception to this (figures are output rather than means of interaction).

Key functions reside in the main directory of the program (one function, getdicomimages.m, is deprecated) and a directory named “GUI” contains some of the newer parts that add a GUI.

An important interface function is called fiesta_simulation.m. The first line of code in this function is a boolean flag that says whether the program should be run in GUI mode or not. If use_gui is 0, then the program will simply run the list of tasks specified below. It is possible to give several jobs for the program to complete this way, e.g. in order to run many experiments overnight. If use_gui is non-zero (probably 1 but not necessarily), then the function is assumed to have been called from the file GUI/cardiomat.m, which is a wrapper that invokes a splash screen and some dialogues that serve as a graphical interface. In turn, parameters fed to these dialogues will be passed to fiesta_simulation.m. It might be necessary to modify some paths inside the files in case the functions and the files are located in different places than the ones specified in parameters. Such paths are named in fiesta_simulation.m, loadtaggedsequence.m (specifies output directories onto which to save figures), and splash.m (looks for program images). For a new user, the only things require modifications are likely to be directory paths and maybe the use_gui boolean, depending on this user’s preference.

To run the program in GUI mode, MATLAB is needed. There is also a parameter to specify in fiesta_simulation.m in order to inform loadtaggedsequence.m whether MATLAB or Octave gets used. It is the boolean which is also the last argument in the function call, being 0 for MATLAB and 1 for Octave. The GUI front end will always pass 0 under the assumption that it is run under MATLAB.

DATASETS

The specified directories include a path from which to open images, optionally with a wildcard to filter bits contained within a given directory, e.g. selecting a subset of images that are a range of numbers. Due to privacy/data anonymity constraints, no raw data accompanies this program, even though it can definitely be obtained from many places (see for example http://schestowitz.com/Weblog/archives/2010/11/14/segmented-and-tagged-datasets/).

COMPATIBILITY

There are separate levels of compatibility dilemmas. One is the program level and another is the operating system level. Although the program has been tested in both MATLAB and Octave, on both GNU/Linux and Windows, there may be trivial code changes to make in case errors show up. Most will be path related, so it is abundantly clear that emphasis should be put on making all functions reachable from within paths definition (e.g. “addpath(genpath(YOUR_PROGRAM_ROOT_DIR_HERE))”) and booleans should be set to do the right thing (GUI/CLI and MATLAB/Octave). The goal is to ensure the program can be run under as many platforms as possible, with either free/libre or proprietary software.

IN CASE OF DIFFICULTIES

If issues running the program are experienced, please contact the author (address above). Bugs are expected to exist (it is a research purposes program, so polish is not a priority) and input is not validated or sanitised to provide virtual ‘rails’ on which the user operates the program (sane values need to be given). Sample function calls are given in fiesta_simulation.m and /Experiments/fiesta_simulation-old-experiments.m. Some of them may use the old interface and thus lack some input arguments, but most of them show the type of experiments which were run using the program.

Retrieval statistics: 22 queries taking a total of 0.144 seconds • Please report low bandwidth using the feedback form
Original styles created by Ian Main (all acknowledgements) • PHP scripts and styles later modified by Roy Schestowitz • Help yourself to a GPL'd copy
|— Proudly powered by W o r d P r e s s — based on a heavily-hacked version 1.2.1 (Mingus) installation —|