kettlepot - photography and blog

Archive for the ‘work’ Category

first day back to work

Tuesday, November 10th, 2009

yesterday was my first day back to work after taking two weeks off for the birth of our son. i feel like i fell a little to easily back in to it. some things had piled up over those weeks, so i was busy from the moment the computer came on and didn’t stop until i left for a doctor appointment and then again until i left to go home. fortunately, the appointment was a nice little break, and i got to see junior sleeping in the back of the car, and that was a very nice treat. and coming home to wife and son was definitely a new experience (even if he was in a mood when i got home!). someday i’ll be coming home from work, and he will greet me at the door. then i’l come home, and he’ll be out with his friends. then off to college. woah! slow down there, buddy. right now, i come home, he eats, cries, and poops. as unexciting as that may sound, i’ll take it any day.

my mac, my eclipse, and my java (oh my!)

Saturday, January 31st, 2009

i think every time i have a list of three things, my natural tendency is to end it with “oh my!”. damn you l. frank baum

we have a few macs at work to support a few different projects, and most of our projects are java-based. this year marks the end of life of java 5 (we’ll miss you!) and my introduction in to mac and java woes. it turns out steve jobs made some disparaging remarks against java, and now sun and java aren’t playing nice together. so much for cross platform, although at this points it is more an inconvenience than doom and gloom.

there are two basic problems. first, there is no 32-bit version of java 6 for the mac, so we had to install the 64-bit version. that normally wouldn’t be a big deal, except that for jni to work, the platform libraries need to be compiled to match the jvm, so all of our 32-bit libraries we built for one of our projects for which we leverage jni need to be recompiled for 64-bit support.

the second problem is eclipse, our development environment. evidently, it does not like the the mac java 6 implementation. good news! you can install java 6, but you can’t use your development environment in java 6! woot!

we did some searching around and came up with (mostly) a solution. here is what we did:

1. first, bite the bullet and install the 64-bit (and only) version of java on the mac.

2. next, make it your default JVM. To do this, use “Applications > Utilities > Java > Java Preferences”. drag the java 6 item to the top of both the applet and application lists. viola! default.

3. reboot.

4. to get eclipse to work, you’ll need to modify the plist file. mine was located in /Applications/eclipse/Eclipse.app/Contents/Info.plist. open it in an editor.

5.  the default Info.plist file has a section near the top that shows you how to use a specific jvm for eclipse. i uncommented out the section for the 1.5 jvm.

6. launch eclipse. it should use the java 5 jvm and come up.

7. one last thing worth doing in eclipse is making sure you have both the 1.5 and 1.6 jres installed. to do this, in eclipse open th eclipse properties and navagate to “Java > Installed JREs”.  click the add button and follow the prompts to add the path for any missing jres. you can also set the default jre here, and you should set the compiler compliance level under “Java > Compiler”.

the kicker is the jni side. for this to work, a few things need to happen.

first, you’ll need to recompile any libraries that you compiled to use with jni for 64-bit, if it isn’t already. in our case, we need the jpcap libraries. to do this, i had to modify the Makefile and specify the “-arch x86_64″ argument to the compiler.  the other piece i had to check was to make sure that my jni references were pointing to the jni.h inside of the java 6 installation. it looks like that’s the bit that really counts for the whole jni thing.

of course, that didn’t work. well, it sort of worked. the jre isn’t complaining about the unsatisfiedlinkerror, but there is something still missing from the jpcap recompile so that some of the calls are not working. but we’ll get there.

ain’t technology fun?

opacity change using perl and gd

Saturday, January 10th, 2009

i’ve got this side project at work that involves capturing images from a cable box and providing reports, including images, on the health of our cable plants. the images include screen captures from the adult content channels, so i wanted to do something to alter the images so you can still see that there is video, but not see…you know…who’s doing what to who.

my first idea was to just change the opacity (or alpha, depending on what school you went to). since the script that checks the channel is in perl, i figured that would be a good place to start, and i already knew about the gd library. i searched around for a bit but couldn’t find anything specifically on point. i did find a reference to adding a watermark to an image, which gave me an idea…merge my image with a white image, and see what happened.

first, the code:

#don’t forget the use GD; at the top of the file
sub filterImage {
my $src_file = shift;
# the src_file is passed in to the subrouting call.
#the higher this value, the more opaque the result will be
my $percent = 75.0;
GD::Image->trueColor(1);
# open source image
#open the file from the file system
$is = GD::Image->new($src_file) or
die(sprintf(“Failed to open \”%s\”", $src_file));
#create another image from scratch, which is basically just a
# big white image the same size as my source image
$iw = new GD::Image($is->width,$is->height);
$white = $iw->colorAllocate(255,255,255);
$iw->fill(0,0,$white);
#merge the two files and apply the transparency value
$is->copyMerge($iw, 0, 0, 0, 0, $iw->width, $iw->height, $percent);
#write out the resulting image; i’m overwriting the source image
open(OUT, “>$src_file”) or die(sprintf(“Failed to write \”%s\”: %s”, $src_file, $!));
# write out resulting image
print(OUT $is->jpeg(70));
close(OUT);
}

that’s it. here a few sample images:

original processed
DSC_0009 opaque

i also found another library that provided some additional filters. since you can, obviously, still see the original image, a few extra lines can do all sorts of stuff:

Erase Line Swirl
eraseline swirl

for that, just add lines similar to these after you save the opaque image:


#don’t forget the use Image::Filter; at the top of the file
$image = Image::Filter::newFromJpeg($src_file);
$image = $image->filter(“blur”); #Load Image::Filter::Blur
$image = $image->filter(“eraseline”,5,1,255,255,255); #Load Image::Filter::Eraseline
$image->Jpeg($src_file);

clean desk, clean mind

Wednesday, October 22nd, 2008

i’ve spent some time each night since we’ve been back getting organized. i’ve organized all of my photography files, at least by year, and put a new snapshot on my server. i’m starting to burn copies of the backups on to DVD, and i just got in the new portable hard drive. backups are good. the more i do my research and want to get more “pro” with everything, i see the value of backups and organization in not only the files, but the process, resources, and equipment, too.

it’s starting to flow into other areas now, this whole organization thing. i can see the glass of the desk in my office at home. things are finding their way back to their places. i went through the box of magazines i have to catch up on and put into recycling the ones that were irrelevant and outdate and made it easier for me to identify the oldest of the issues i did keep. i organized the units from my photography class, and have the bundle ready for the unit on which i am currently working so that i can jump back in to it.

it feels good. the honeymoon put a lot of things in perspective, and i’m glad the flight back didn’t squash my good intentions. i’ve even started making lists again, which got really long, really fast. but it seemed to make things easier when i actually stayed on top of them, and they still work great at work. i added a photography project to the list that i want to work on, on top of working on the honeymoon “keepers”. i’ve set a few goals for myself in a few different areas, too. they should be realistic, and accomplishing them will give me a rewarding feeling to build bigger goals. perspective is good. realizing it’s a journey and enjoying the trip is better.

you know, only two things come out of that place…

Tuesday, July 8th, 2008

a quick post tonight, but i wanted to at least write something to keep with last nights post. i’m headed to bed early, for tomorrow i shall rise and get on an early flight to texas. i’ve actually never been there before, so it’s a new place to see, even if just for a short trip. i think i’ve gotten to used to not traveling in the past 3 weeks that i haven’t had to go anywhere, speaking of routines. it should be alright, though. we’ll be meeting a vendor that i’ve needed an “in” to for awhile, and i get to see some colleagues from the east coast that i don’t get to see much anymore. oh, and i started learning a new song. all in all, a crazy busy day, a short, early evening, and tomorrow is a whole different animal (i’m flying frontier!).