Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - kulesz

Pages: [1]
1
Graphics / Problem with using webcam - slow copying to image
« on: March 20, 2011, 05:48:43 pm »
It's a Samsung N140 netbook, so it's actually Intel 945GSE chipset. I know it's weak, but it's my requirement for the application to run on such a graphic card.

2
Graphics / Problem with using webcam - slow copying to image
« on: March 20, 2011, 11:52:10 am »
Just tried it - it's doesn't affect performance at all :-/

3
Graphics / Problem with using webcam - slow copying to image
« on: March 20, 2011, 11:48:44 am »
Copying from buffer to image is the only thing I'm doing here - the same program on Allegro, with changed just a few lines - works faster. Nothing else in the program doesn't slow down the capture, only altering the width and height parameters of LoadFromPixels changes the loading speed.

4
Graphics / Problem with using webcam - slow copying to image
« on: March 20, 2011, 10:54:08 am »
Hi,

I'm trying to use SFML with a webcam library (videoInput), but copying data (pixels) from camera buffer to image seems to be very slow - the video is no more than 5fps :-/ The same code written in Allegro runs few times faster. Is it some way to fasten it up? I'm using SFML v.1.6.

Code:

Code: [Select]

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
    // Create the main rendering window
App.Create(sf::VideoMode(800, 550, 32), "SFML Graphics");
cam1.Init(640,480);

    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear the screen (fill it with black color)
        App.Clear();
cam1.Draw(&App);
        // Display window contents on screen
        App.Display();
App.SetFramerateLimit(60);
    }

    return EXIT_SUCCESS;
}


And webcam functions:
Code: [Select]

int CCamera::Init(int width, int height)
{
if (!VI.setupDevice(device, width, height)) return 1;
VI.setIdealFramerate(device, 25);
w = VI.getWidth(device);
h = VI.getHeight(device);
size = VI.getSize(device);
buffer = new unsigned char[size];
buffer2= new unsigned char[w*h*4];
  image.Create(w, h, sf::Color(230, 230, 230));
image.SetSmooth(false);
sprite.SetImage(image);
return 0;
}


void CCamera::Draw(sf::RenderWindow * app)
{

if(VI.isFrameNew(device))
{
//Here I take the buffer of RGB values
VI.getPixels(device, buffer, true, true);
int z=0;
//Transform it into ARGB
for (int u=0; u<w*h*3; u+=3)
{
buffer2[z]=buffer[u];
buffer2[z+1]=buffer[u+1];
buffer2[z+2]=buffer[u+2];
buffer2[z+3]=255;
z+=4;
}
// And this is the problem - loading seems to be so slow
image.LoadFromPixels(w,h,buffer2);
}

app->Draw(sprite);
}

Pages: [1]