Hi,

I am implementing real time computer vision application using X10, to figure
out X10 can help in computationally intensive streaming applications.
At this point, I am trying to use existing C++ library's I/O functions since
they can read lots of different formats, including avi and jpeg.

While implementing, I found that copying each pixel in image from C to X10
introduces significant overhead. Essentially, this is what I'm doing :

X10

class X10Image
{
        public val width : Int;
        public val height : Int;
        public val channel : Int;
        public val img : Array[Int];
        ....
}

class Main
{
        public static def main (Array[String])
        {

                val I : X10Image = null;
                val fn : String = "test.avi";
                { @Native("c++","I = load_x10img(fn->c_str());") {} }
                .....
        }
}

C++

x10aux::ref<X10Image> load_x10img(const char* fn)
{
        IplImage* pImg = cvLoadImage(fn);
        uchar* data = (uchar *)pImg->imageData;

        x10aux::ref<X10Image> x10Img = X10Image::_make(pImg->width,
pImg->height, pImg->nChannels);

        for(int y=0;y<pImg->height;y++)
                for(int x=0;x<pImg->width;x++)
                        for(int c=0;c<pImg->nChannels;c++)

x10Img->FMGL(img)->set(data[y*step+x*channels+c], x, y, c);

        cvReleaseImage(&pImg);

        return x10Img;
}

Here I instantiate X10 data structure in C++ using _make and copy each pixel
of image data structure to X10 image data structure.
Is there any way to do this more efficiently? For example, can I copy array
in bulk? Or can I even set the C++ array as X10 Array's backing storage?

Thanks,
Kirak
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to