how to capture skeleton image every 10 minutes by kinect? C#












0















I want to capture an image every 10 minutes by kinect. but I don't know how
I want to save image to folder mypicture.(or any folder) I try to edit from sample file of SDK kinect (body basic file&coordinate mapping basic)
here is my code



private void startSaveTimer()
{
Timer saveTimer = new Timer(600000);
saveTimer.Elapsed += saveTimer_Elapsed;
saveTimer.Start();
}

private void saveTimer_Elapsed(object sender, ElapsedEventArgs e)
{



// Create a render target to which we'll render our composite image
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)CompositeImage.ActualWidth, (int)CompositeImage.ActualHeight, 96.0, 96.0, PixelFormats.Pbgra32);

DrawingVisual dv = new DrawingVisual();
using (DrawingContext dc = dv.RenderOpen())
{
VisualBrush brush = new VisualBrush(CompositeImage);
dc.DrawRectangle(brush, null, new Rect(new Point(), new Size(CompositeImage.ActualWidth, CompositeImage.ActualHeight)));
}

renderBitmap.Render(dv);

BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));

string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);

string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

string path = Path.Combine(myPhotos, "KinectScreenshot-bodybasic-" + time + ".png");

// Write the new file to disk
try
{
using (FileStream fs = new FileStream(path, FileMode.Create))
{
encoder.Save(fs);
}
if (this.StatusText == null)
{
this.StatusText = string.Format(Properties.Resources.SavedScreenshotStatusTextFormat, path);
}
}
catch (IOException)
{
this.StatusText = string.Format(Properties.Resources.FailedScreenshotStatusTextFormat, path);
}
}


please help me! ,Thanks










share|improve this question























  • are you getting any error ? What is the expected output from this ?

    – Manoj Choudhari
    Jan 19 at 12:01











  • @ManojChoudhari it not error but image is not go to folder that I was set it. It has nothing.

    – capture
    Jan 19 at 12:04













  • Is startSaveTimer() getting evaluated? Or saveTimer_Elapsed?

    – Wai Ha Lee
    Jan 19 at 14:18











  • @WaiHaLee I think saveTimer_Elapsed

    – capture
    Jan 19 at 15:27
















0















I want to capture an image every 10 minutes by kinect. but I don't know how
I want to save image to folder mypicture.(or any folder) I try to edit from sample file of SDK kinect (body basic file&coordinate mapping basic)
here is my code



private void startSaveTimer()
{
Timer saveTimer = new Timer(600000);
saveTimer.Elapsed += saveTimer_Elapsed;
saveTimer.Start();
}

private void saveTimer_Elapsed(object sender, ElapsedEventArgs e)
{



// Create a render target to which we'll render our composite image
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)CompositeImage.ActualWidth, (int)CompositeImage.ActualHeight, 96.0, 96.0, PixelFormats.Pbgra32);

DrawingVisual dv = new DrawingVisual();
using (DrawingContext dc = dv.RenderOpen())
{
VisualBrush brush = new VisualBrush(CompositeImage);
dc.DrawRectangle(brush, null, new Rect(new Point(), new Size(CompositeImage.ActualWidth, CompositeImage.ActualHeight)));
}

renderBitmap.Render(dv);

BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));

string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);

string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

string path = Path.Combine(myPhotos, "KinectScreenshot-bodybasic-" + time + ".png");

// Write the new file to disk
try
{
using (FileStream fs = new FileStream(path, FileMode.Create))
{
encoder.Save(fs);
}
if (this.StatusText == null)
{
this.StatusText = string.Format(Properties.Resources.SavedScreenshotStatusTextFormat, path);
}
}
catch (IOException)
{
this.StatusText = string.Format(Properties.Resources.FailedScreenshotStatusTextFormat, path);
}
}


please help me! ,Thanks










share|improve this question























  • are you getting any error ? What is the expected output from this ?

    – Manoj Choudhari
    Jan 19 at 12:01











  • @ManojChoudhari it not error but image is not go to folder that I was set it. It has nothing.

    – capture
    Jan 19 at 12:04













  • Is startSaveTimer() getting evaluated? Or saveTimer_Elapsed?

    – Wai Ha Lee
    Jan 19 at 14:18











  • @WaiHaLee I think saveTimer_Elapsed

    – capture
    Jan 19 at 15:27














0












0








0








I want to capture an image every 10 minutes by kinect. but I don't know how
I want to save image to folder mypicture.(or any folder) I try to edit from sample file of SDK kinect (body basic file&coordinate mapping basic)
here is my code



private void startSaveTimer()
{
Timer saveTimer = new Timer(600000);
saveTimer.Elapsed += saveTimer_Elapsed;
saveTimer.Start();
}

private void saveTimer_Elapsed(object sender, ElapsedEventArgs e)
{



// Create a render target to which we'll render our composite image
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)CompositeImage.ActualWidth, (int)CompositeImage.ActualHeight, 96.0, 96.0, PixelFormats.Pbgra32);

DrawingVisual dv = new DrawingVisual();
using (DrawingContext dc = dv.RenderOpen())
{
VisualBrush brush = new VisualBrush(CompositeImage);
dc.DrawRectangle(brush, null, new Rect(new Point(), new Size(CompositeImage.ActualWidth, CompositeImage.ActualHeight)));
}

renderBitmap.Render(dv);

BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));

string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);

string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

string path = Path.Combine(myPhotos, "KinectScreenshot-bodybasic-" + time + ".png");

// Write the new file to disk
try
{
using (FileStream fs = new FileStream(path, FileMode.Create))
{
encoder.Save(fs);
}
if (this.StatusText == null)
{
this.StatusText = string.Format(Properties.Resources.SavedScreenshotStatusTextFormat, path);
}
}
catch (IOException)
{
this.StatusText = string.Format(Properties.Resources.FailedScreenshotStatusTextFormat, path);
}
}


please help me! ,Thanks










share|improve this question














I want to capture an image every 10 minutes by kinect. but I don't know how
I want to save image to folder mypicture.(or any folder) I try to edit from sample file of SDK kinect (body basic file&coordinate mapping basic)
here is my code



private void startSaveTimer()
{
Timer saveTimer = new Timer(600000);
saveTimer.Elapsed += saveTimer_Elapsed;
saveTimer.Start();
}

private void saveTimer_Elapsed(object sender, ElapsedEventArgs e)
{



// Create a render target to which we'll render our composite image
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((int)CompositeImage.ActualWidth, (int)CompositeImage.ActualHeight, 96.0, 96.0, PixelFormats.Pbgra32);

DrawingVisual dv = new DrawingVisual();
using (DrawingContext dc = dv.RenderOpen())
{
VisualBrush brush = new VisualBrush(CompositeImage);
dc.DrawRectangle(brush, null, new Rect(new Point(), new Size(CompositeImage.ActualWidth, CompositeImage.ActualHeight)));
}

renderBitmap.Render(dv);

BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));

string time = System.DateTime.Now.ToString("hh'-'mm'-'ss", CultureInfo.CurrentUICulture.DateTimeFormat);

string myPhotos = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);

string path = Path.Combine(myPhotos, "KinectScreenshot-bodybasic-" + time + ".png");

// Write the new file to disk
try
{
using (FileStream fs = new FileStream(path, FileMode.Create))
{
encoder.Save(fs);
}
if (this.StatusText == null)
{
this.StatusText = string.Format(Properties.Resources.SavedScreenshotStatusTextFormat, path);
}
}
catch (IOException)
{
this.StatusText = string.Format(Properties.Resources.FailedScreenshotStatusTextFormat, path);
}
}


please help me! ,Thanks







c# wpf kinect capture






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 19 at 11:56









capturecapture

1




1













  • are you getting any error ? What is the expected output from this ?

    – Manoj Choudhari
    Jan 19 at 12:01











  • @ManojChoudhari it not error but image is not go to folder that I was set it. It has nothing.

    – capture
    Jan 19 at 12:04













  • Is startSaveTimer() getting evaluated? Or saveTimer_Elapsed?

    – Wai Ha Lee
    Jan 19 at 14:18











  • @WaiHaLee I think saveTimer_Elapsed

    – capture
    Jan 19 at 15:27



















  • are you getting any error ? What is the expected output from this ?

    – Manoj Choudhari
    Jan 19 at 12:01











  • @ManojChoudhari it not error but image is not go to folder that I was set it. It has nothing.

    – capture
    Jan 19 at 12:04













  • Is startSaveTimer() getting evaluated? Or saveTimer_Elapsed?

    – Wai Ha Lee
    Jan 19 at 14:18











  • @WaiHaLee I think saveTimer_Elapsed

    – capture
    Jan 19 at 15:27

















are you getting any error ? What is the expected output from this ?

– Manoj Choudhari
Jan 19 at 12:01





are you getting any error ? What is the expected output from this ?

– Manoj Choudhari
Jan 19 at 12:01













@ManojChoudhari it not error but image is not go to folder that I was set it. It has nothing.

– capture
Jan 19 at 12:04







@ManojChoudhari it not error but image is not go to folder that I was set it. It has nothing.

– capture
Jan 19 at 12:04















Is startSaveTimer() getting evaluated? Or saveTimer_Elapsed?

– Wai Ha Lee
Jan 19 at 14:18





Is startSaveTimer() getting evaluated? Or saveTimer_Elapsed?

– Wai Ha Lee
Jan 19 at 14:18













@WaiHaLee I think saveTimer_Elapsed

– capture
Jan 19 at 15:27





@WaiHaLee I think saveTimer_Elapsed

– capture
Jan 19 at 15:27












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54266816%2fhow-to-capture-skeleton-image-every-10-minutes-by-kinect-c-sharp%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54266816%2fhow-to-capture-skeleton-image-every-10-minutes-by-kinect-c-sharp%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Liquibase includeAll doesn't find base path

How to use setInterval in EJS file?

Petrus Granier-Deferre