Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility of multi-thread #1

Open
soudazhou opened this issue Feb 28, 2013 · 3 comments
Open

Possibility of multi-thread #1

soudazhou opened this issue Feb 28, 2013 · 3 comments
Assignees

Comments

@soudazhou
Copy link

Hi Latish,

Thanks a lot for your solution which does exactly what I need. I have noticed a slightly latency in the display of video on the UI during the recording, which I suppose could be solved by multi-thread. I have tried to use Backgroundworker Class to put the recording on a different thread than the UI, but got a error when I call bw.RunWorkerAsync(e); I will briefly explain my current solution below:

void KinectSensorAllFramesReady(object sender, AllFramesReadyEventArgs e)
{

        bw.RunWorkerAsync(e);
        //System.Console.WriteLine(" frame");
        using (var frame = e.OpenColorImageFrame())
        {

            if (frame != null)
            {
               // if (recorder != null)
               //     recorder.Record(frame);
                UpdateColorFrame(frame);
            }
        }

        using (var frame = e.OpenDepthImageFrame())
        {
            if (frame != null)
            {
                if (recorder != null)
                    recorder.Record(frame);
            }
        }

        using (var frame = e.OpenSkeletonFrame())
        {
            if (frame != null)
            {
                if (recorder != null)
                    recorder.Record(frame);
                UpdateSkeletons(frame);
            }
        }
    }

During the initialization, I declared a Backgroundworker object bw, and attached the eventhandler bw_DoWork o it, so it will record in another thread rather than the UI thread.

    private void bw_DoWork(object sender, DoWorkEventArgs e)
    {
        BackgroundWorker worker = sender as BackgroundWorker;
        var arg = (AllFramesReadyEventArgs)e.Argument;
        var frame = (ColorImageFrame)arg.OpenColorImageFrame();
               if (frame != null)
            {
                if (recorder != null)
                    recorder.Record(frame);
            }
    } 

However, it will lead to "This BackgroundWorker is currently busy and cannot run multiple tasks concurrently." Which I suppose a new BackgroundWorker Object is needed for every frame?

Would be great if you could provide me some hints on how to put the recording on a separate thread so the color image display on the UI won't lag while recording, thanks.

Regards,

Wenxuan

@ghost ghost assigned latish Feb 28, 2013
@latish
Copy link
Owner

latish commented Feb 28, 2013

I'll try to look at this over the weekend.
Assuming you have decent enough hardware to run this on, It's been my experience that sometimes the kinect data can get sluggish, and just unplugging and reinserting the kinect usb cable usually seems to fix it.

@MrImam
Copy link

MrImam commented Oct 11, 2016

hey, if it can be used to replay kinect kinect for windows 2 ?

@MrImam
Copy link

MrImam commented Oct 11, 2016

kinectreplay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants