Although this is not fitting into the mobile communication categories I’m a big fan of JBoss Seam framework. Since I’m an experienced Java EE developer it gives me everything I need for modern web based applications.
Recently I was looking int a way of integrating a (web)cam into my project as platform independend as possible. I’ve often seen Flash applications using the integrated camera of my MacBook Pro so I started looking in this direction. I learned that Flex which is in my understanding some kind of Flash extension for Application development makes it very easy to utilize a camera, display the videostream and take snapshoots. In fact you only need some lines of code after all ui elements are in place:
private var cam:Camera;
private function setUpCam():void {
cam = flash.media.Camera.getCamera();
cam.setMode(320, 240, 30);
videoDisplay.attachCamera(cam);
}
It’s important that the camera resolution (setMode()) matches the size of the video display. Otherwise the videostream will conatin artifacts.
To get a snapshot just call the following function:
private function saveImage():void {
var bitmapData:BitmapData = new BitmapData(vid.width, vid.height);
bitmapData.draw(videoDisplay);
var encode:JPGEncoder = new JPGEncoder();
var imageData:ByteArray = encode.encode(bitmapData);
}
After accessing the camera was so easily done (up to this day I didn’t write a single line of Flex or ActionScript code) I looked further into integrating this application with my main seam application.
Two frameworks exists for this task. First there is Flamingo from Exadel. I looked at the documentation and examples but was not able to find a way to just call a method of a seam component and pass a byte array. I’m sure it will work somehow. Since the last release is from October 2008 I was uncertain if it would work with the current 2.1 release of Seam.
I then discovered Granite DS as an alternative. There has been a recent update and a separate version vor Seam 2.1 exists. Although more steps where needed to integrate the framework into my Seam Application. However I was finally able to pass Objects and values back and forth.
After this first success I will be looking into more details of Granite DS. I wonder if security and context propagation are working as promised.
Hinterlasse einen Kommentar