Category: Programming

Setting Manual Exposure in OpenCV

11 June, 2017 (14:01) | Snippets, Programming, Code, Python, OpenCV

In OpenCV, you can set the exposure for your camera manually by using the VideoCapture::set method. What isn’t obvious is what value to pass in for it. I have experimented with various webcams and the below settings seem to be accurate enough. Not all cameras allow setting the exposure programatically, so if […]

Android: Simple Example of Page Transition Using ViewPager

17 May, 2015 (18:54) | Java, Snippets, Programming, Code, Android

The ViewPager class built in to the Android SDK is a simple method of showing an animated transition between two views. For example, turning a page, or a calendar scrolling through months. This functionality can be added with only a few lines of code. Below I present an example containing pretty much […]

A Quick Snippet for Drawing Images in Java

2 October, 2014 (02:22) | Java, Snippets, Programming, Code, Android

Java does not have the best built-in tools in the world for drawing images, but it’s still useful for many purposes. Below is just a snippet on getting started drawing in Java. For more information on what’s available see the Java Graphics class reference.

BufferedImage i = new BufferedImage(500, 500,BufferedImage.TYPE_INT_RGB);
Graphics g=i.createGraphics();
g.drawLine(0, 0, 500, 500);
g.drawString(”This […]

A basic 3d to 2d projection

2 October, 2014 (02:09) | .Net, Programming, C#, Code, Computer Science

Developing an actual 3D engine is an incredible amount of work, and including a 3D library in your project can add a considerable amount of bloat to your project. Fortunately you can implement some very simple 3D projections in just a couple of lines of code, and they are not computationally intensive. There […]

Android: Accessing other views from inside a custom view using findViewById().

1 October, 2014 (11:15) | Java, Snippets, Programming, Android

If you attempt to call findViewById() on the ID of a view that is not from the Activity that holds the view, findViewById() returns null. I’ve seen a lot of solutions posted for attempting to access a View from outside the activity that created it. Most of them involve inflating the original view […]

Why you should return “this” from your setter methods.

26 September, 2014 (21:35) | .Net, Java, Snippets, Programming, C#, Code

Fortunately most API designers know to use this technique, but it’s still pretty common to find some that do not. It’s generally good practice, that when writing a setter method for a class, that you return the object’s “this” rather than “void”. The reason is that it allows a user of your class […]

Resurecting a broken Android phone as a development sandbox for app development.

24 August, 2014 (22:17) | Java, Programming, Operating Systems, Android

I had the unfortunate incident of cracking the screen on my fairly new Galaxy S5. Since most of the phone worked, I wanted to get all of my old data off, on to my new phone, and finally re-purpose the old phone as a development sandbox which I can dedicate to Android app development. […]

How To Measure Any Distance With The Pythagorean Theorem

8 July, 2013 (18:23) | Programming

Interesting article on how to use the Pythagorean Theorem to measure distances of non-spatial domains.

List of my favorite free/open source utilities 2012

8 September, 2012 (23:17) | Windows, Linux, Programming

While I’ve been a huge fan of Scott Hanselman’s Tool List, but was pretty disappointed in the 2011 list in that it lacked conciseness. Below is a short list of software I use on a very regular basis, install on pretty much every PC that I can, and are all tools I know very […]

Copying text and HTML to the clipboard at the same time from a Firefox add-on

8 July, 2011 (10:07) | JavaScript, Programming

The JavaScript code below demonstrates how to copy two different formats of data to the clipboard at the same time. So applications wanting only text can grab the text version, but applications supporting HTML can grab that version instead. The basic idea is that you call addDataFlavor() for each type of data you […]