actionscript-3flashapache-flexstage3dagal

Can I use AS3 Stage3D AGAL to achieve CUDA like processing?


I have a program what detects a ball in a 320x240 stream runtime, but if I stream bigger resolution, it gets too slow. I'm assuming if I could use the GPU to calculate each pixels (with their neighbor frames, and neigbor pixels) it would be faster. Anyone knows if I can get data BACK from the GPU with AGAL?

in sort, I have the loop below, what goes through each pixel of the frame, and I want to calculate the most on GPU, to achive better performance.

for(var i:int=cv.length-1; i>1;i--){
                if( (110*255) < (cv[i] & 0x0000FF00) && (cv[i] & 0x0000FF00) < (150*255)){ //i zöld
                    if(  (cv[i+2] & 0x0000FF00) > (150*255) ) { //i+2 világos
                        if(floodhere(cv, i+2)){ //méret nagy
                            prevDiff[i]=0xffffffff; //fehér
                            close.push(i);
                        }
                        else prevDiff[i]=0xffff0000 //méret kicsi -> piros
                    } else {
                        prevDiff[i]=0xff000055 //kék
                    }
                } else {
                    prevDiff[i]=0xff000000 //fekete
                }
            }

Solution

  • You may be able to use PixelBender. It also works in separate thread(s) and makes use of multicore CPUs so is much quicker than actionscript.

    See http://www.flashmagazine.com/tutorials/detail/using_pixel_bender_to_calculate_information/ for an example