TrueJournals

Archive for March, 2013

My First Open Source Library: libptp++

by on Mar.03, 2013, under programming

I’ve been working on it for a while, but since I’ve made the code public, it’s time for an official announcement: libptp++ is ready!

When working on my project for senior design, part of the challenge was being able to communicate with a Canon camera, and be able to send commands to CHDK.  There’s an excellent python library that does the job, but running on the Raspberry Pi, it was really slow.  After doing some more benchmarking and testing, I determined that Python was just going to be slow on the Raspberry Pi, and it was time to move on to a different language.

I decided to pick C++ for a few reasons:

  1. It’s just about as fast as you can get.  I’m sure there are people who will say that it’s not quite as fast as C, but it’s going to be pretty close.  Having a compiled language is much faster than any interpreted language.
  2. It’s object-oriented.  I felt that pyptp2 had a great API, and was already accustomed to using it.  With an object-oriented language, I could simply implement this existing API.  I also feel that objects provide great assistance to the programmer.
  3. I wanted to.  I’ve been wanting to get into C++ and see what the syntax is like and what it’s capable of, but haven’t had a good chance to.  This provided me this opportunity.

So, I started work on building a PTP library in C++.  I’ll note here that there IS a PTP library in C.  However, I had a lot of trouble figuring out how to use this library (it’s heavily tied in to the ptpcam program it comes with), and all CHDK extensions I could find were poorly documented, and, again, tied heavily to some other program.

Having said all that, I’m very proud with where libptp++ is.  It’s as functionally complete as I need it for my senior design project, but I’m still working on expanding it.  The CHDKCamera class it provides is mostly complete, but the PTPCamera (for camera’s that don’t or can’t run CHDK) is unimplemented.  Going forward, I’ll need to look into what functionality that class will need to provide.

I’ll also note that I did my best to document everything using Doxygen strings.  One of my complaints about libptp2 is that it’s poorly documented, so I don’t want to run into the same trap.  Run libptp++ through Doxygen and you’ll get some wonderful documentation.  There’s even an example included in there!

I’m releasing this code under the LGPLv3.  Basically, this means (to my understanding) that you can use it however you want, as long as you release the source code.  Additionally, the LGPL allows this library to be included in commercial products.  Again, though, the source code must be provided.

I hope someone else can get some use out of this library!  It’s certainly not perfect, but its current state is a good start.  I encourage anyone that finds a bug to file an issue on GitHub, or fork the project, fix the bug and send in a pull request!

https://github.com/TrueJournals/libptp–

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...