| Days | |
| Hours | |
| Minutes | |
| Seconds |
I started yet another project a few weeks ago. This one, called libvcvideo, is intended to be a super simple way to access video devices, especially web cams. I’ve been writing it to replace the more feature rich, but heavier OpenCV in my other projects. Yesterday in class I got the first working product, so I made a flurry of refinements, added some documentation, and I’m now showing it off.
It’s nothing amazing yet, it only works in Linux on V4L devices that are web cams and use the RGB24 data format. That said, it’s still a lot of devices, especially from the spca5xx and gspca drivers.
I’ll be adding more to it over time, but here is some proof of concept items.
Here is a fullscreen shot of the library running my gtkmm test program. The library was compiled with it’s debug option which provides all that information in the terminal window.
One cool thing I added is a sigc++2 signal for measuring the progress of operations. Here I have it hooked up to my gtkmm test program showing where it is in the initialization process.
Here is the first image I captured with the library. If it looks a little off color, it is because I hadn’t corrected the byte ordering on the format yet, so blue and red are swapped. Yes, it is a boring first image, but the camera was under my desk and I didn’t want to offend the teacher by openly working on this during a macroeconomics lecture.
Here is about the most simple example possible. It safely creates, opens, initializes, and grabs a frame from the device “/dev/video0″.
#include <iostream > using std::cerr; using std::endl; #include <string > using std::string; #include "lib/videoDevice.h" int main (int argc, char ** argv) { vc::videoDevice device ("/dev/video0"); vc::vdFrame frame; try { device.init(); } catch(string s) { cerr << "Device initialization failed: " << s << endl; exit(1); } try { device.getFrame(frame); } catch(string s) { cout << "Failed to get frame: " << s << endl; exit(1); } }
You can get more details on the project page.
Posted June 18th, 2008 - PermalinkFirst of all, no, I haven’t ditched my fiancĂ©e Darcy. I’m talking about the flexible powerful plain text editor that comes with KDE. I’m personally of the opinion that full blown IDE’s are way over rated. I used Anjuta for about 6 months at work, and it really didn’t impress me. My other issue is that I program in a bunch of languages. I tend to have projects going in 2 or 3 languages at once, and I haven’t found a consistent IDE that covers C++, PHP and JavaScript well at the same time. Don’t even say Eclipse, that thing is just ungainly.
So what to do? Well I ended up just going with the plain text editor of KDE, called Kate. Over time I’ve found some really great features that make this a flexible and powerful editor. These are just a few of them.
The Basics
The basics of configuring Kate are as powerful as any other “advanced” text editor. I trim down those fat tabs to being just two spaces wide, turn off wrapping and turn on the line numbering. Last I turn off automatic backups, because the tilde files are annoying and real men don’t program with nets ;-). This is not a complete list of the core features by far, just about everything is configurable.
Highlighting
Syntax highlighting in Kate is very good, and handles oodles of languages. Plus it’s colors are configurable by an easy interface. You probably won’t change them though, as they are fairly consistent between languages, so variables will still look like variables even when you switch languages.
Bookmarks
This is one I didn’t find until recently, but you can bookmark locations in files and jump there real quick. The shortcut it CTRL-B, and I usually use it when I’m working somewhere and need to reference some other code. I bookmark my spot then scroll away to the code I need to look at. Getting back is easy through the bookmarks menu, or if you are above it you can use the shortcut ALT-Page Down or if you are below it, ALT-Page Up.

Sidebar
The sidebar is a powerful part of Kate. There are many plug-ins which can take advantage of the sidebar (which can actually be any combination of left, right, top or bottom bars). The ones I use are the C++ symbol viewer, the file list and the file chooser. The symbol viewer is handy for jumping around your files in C++, I use it a lot along with the bookmarks to check on code quickly. The file chooser is pretty standard, with a list view that includes icons for checking file type. Last is the file list. All your open files are in here. Two short cuts you will want to know are ALT-(Left Arrow) and ALT-(Right Arrow) which will scroll you through the file list. This is very handy for switching between files without leaving the keyboard. The file list is also “heat mapped” with colors on the last files you’ve been in. When closing a file (CTRL-W) you jump to the last file you were in.

Sessions
Kate stores all of its setting in sessions, which you can name and arrange as you wish. This is handy as is, but there is integration with a KDE menu bar widget that makes them even better. This KDE sessions menu is great for jumping straight into projects and picking up right where you left off.

Useful Dialogs
There are several useful tool dialogs in Kate too. The first one is the GoTo dialog, invoked with CTRL-G. This is great for jumping to lines when fixing compile errors or debugging. The other handy one is Find and Replace. There are flexible regular expressions built in, with place holders for the replace dialog. I use this a lot when creating setters and getter for my methods. A few slick regex’s and they are all written.


Auto-Complete
The last feature is the helpful auto-complete. It’s not terribly intelligent, it won’t track down things by symbols and types, but it does the job and when it kick in is configurable, I have it set so after I type 3 characters it pops up suggestions.
I hope that this quick overview of Kate is helpful to someone, I just wanted to share my love for it. Good luck with your endeavors!
Posted June 12th, 2008 - PermalinkI got libcvfx compiled on Windows with Dev-C++. I don’t have it as a library or anything, just got the demo working for now, proof of concept if you will. It was a bit slower on Windows, and I didn’t get the 640×480 out of my web cam. Additionally the highgui didn’t register the arrow keys right so I had to change those.
What I was really wanting to see was if it would run in Windows at all. This would possibly open up a bigger range of web cams for the CameraBooth project, perhaps some of the higher end, higher resolution ones.
Anyway, here’s a screen of it running on Windows and one on Linux for good measure. Click through for the big images.
Additionally I’ve added a few new effects since the last post. Some don’t capture well, so I’ll just describe those ones.
Photo Copy
This one takes a threshold and any pixel under the threshold is turned black, any pixel over it is turned a user specified color, default is white. This tends to be harsh, it might be good to run a blur on it or maybe set a few midpoint values between black and the color to fuzz it a bit.

HStripFlip
Cuts the image into as many strips as you want, then flips every other strip. Defaults to 4 strips.

Corners
This isn’t a new effect, but now you can choose which corners to exchange.
There are a number of effects I didn’t take pictures for.
VStripFlip is like HStripFlip except vertical.
Broken Television is a motion effect where the image scrolls like an out of sync TV. Hard to describe really.
Noise just injects pseudo-random pixels into the image, but it does a poor job of it right now.
Interlace Lines replaces every other horizontal line with all black.
I’ll have more about these effects as well as pictures and maybe video once I get a project page set up for libcvfx. For now you can hit up the repo for source, or grab the Window binary here. You will need the OpenCV libraries installed, and in your PATH.
Posted March 29th, 2008 - PermalinkHere’s a modification of a bash script I made a while back to convert anything that mplayer can play into an mp3 file. Change bitrates and the like to taste.
1 2 3 4 5 6 7 8 9 10 11 | #!/bin/bash # # any2mp3 # for i in *.$1; do mplayer -vc null -vo null -ao pcm:fast "$i" -ao pcm:file="${i%.$1}.wav" done for i in *.wav; do lame -h -V2 --vbr-new "$i" "${i%.wav}.mp3" done rm *.wav |
Say you are in a directory of m4a files, just run any2mp3.sh m4a and wait.
Posted March 18th, 2008 - PermalinkI found VirtualBox “Seamless Mode” a while back and thought I’d post some screens. Actually comes in handy, no more desktop switching. Also just has a certain “wow” factor. Click through for the big versions.
Posted February 19th, 2008 - Permalink