Archive for computervision
Augmented Reality in 2D
Juli 8th, 2009 • 3 comments ar, computervision, creative, flash, hot, idea, lab, nerdlab
Once again I experimented with webcam, augmented reality and flash. Inspired by camspace.com this time I wanted to see if its posible to map a video on a rect which is moved and resized by colored objects.
Tracking Michael Jackson’s glove
Juli 6th, 2009 • art, computervision
Tracking as phantastic collective piece of art. Love it!
Optimized edge detection algorithm.
Juli 1st, 2009 • computervision, math, snippet
I optimized the edge detection (sobel) algorithm found here a little. Still there is a lot potential for optimizing things. You can find tipps in joa’s wiki
Here is my code
private function detectEdges(bmd : BitmapData) : void { var myGausianFilter : ConvolutionFilter = new ConvolutionFilter(5, 5, [2,4,5,4,2,4,9,12,9,4,5,12,15,12,5,4,9,12,9,4,2,4,5,4,2], 115); // Edge Data findEdges(); function findEdges() : void { //Apply Smoothing Filter bmd.lock(); bmd.applyFilter(bmd, bmd.rect, new Point(0, 0), myGausianFilter); //Create New Bitmap to hold edge data ourEdgeData = new BitmapData(bmd.width, bmd.height, false); var gx : int;; var gy : int; var gray : uint; //Loop through original data and calculate edges for(var w : int = 0;w < bmd.width; w++) { for(var h : int = 0;h < bmd.height; h++) { pV0 = int(bmd.getPixel(w, h - 1)/ uint(0xffffff)*255); pV45 = int(bmd.getPixel(w + 1, h - 1)/ uint(0xffffff)*255); pV90 = int(bmd.getPixel(w + 1, h)/ uint(0xffffff)*255); pV35 = int(bmd.getPixel(w + 1, h + 1)/ uint(0xffffff)*255); pV80 = int(bmd.getPixel(w, h + 1)/ uint(0xffffff)*255); pV225 = int(bmd.getPixel(w - 1, h + 1)/ uint(0xffffff)*255); pV270 = int(bmd.getPixel(w - 1, h)/ uint(0xffffff)*255); pV315 = int(bmd.getPixel(w - 1, h - 1)/ uint(0xffffff)*255); gx = (pV45+(pV90*2)+pV35)-(pV315+(pV270*2)+pV225); gy = (pV315+(pV0*2)+pV45)-(pV225+(pV80*2)+pV35); gray = Math.abs(gx) + Math.abs(gy); // Check to see if values aren't our of bounds if(gray > 255) gray = 255; if(gray < 0) gray = 0; // Build New Pixel newPixelValue = (gray << 16)+(gray << 8)+(gray); // Copy New Pixel Into Edge Data Bitmap ourEdgeData.setPixel(w, h, newPixelValue); } } bmd.unlock(); } function getGray(pixelValue : uint) : uint { var red : uint = (pixelValue >> 16 & 0xFF) * 0.30; var green : uint = (pixelValue >> 8 & 0xFF) * 0.59; var blue : uint = (pixelValue & 0xFF) * 0.11; return (red + green + blue); } _bmp3.bitmapData = ourEdgeData; }




