Kinect가 이미지를 가져 와서 사용자가 지정한 위치에 저장하는 프로그램이 있습니다. 나는 그것이 다른 종류의 이미지를 저장하기 위해 더 많은 폴더를 생성하기 때문에 프로그램이 올바른 폴더를 찾는다는 것과 그 폴더가 생성된다는 것을 안다. 이미지를 저장하기위한 내 현재 코드 (아래)는 다른 프로그램에서도 작동하므로, 인식하지 못하는 부분이 멈추고 있습니까? 미리 감사드립니다. 이미지 경로내 프로그램이 이미지를 저장하지 않는 이유는 무엇입니까?
결정 을using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame == null)
{
return;
}
byte[] pixels = new byte[sensor.ColorStream.FramePixelDataLength];
//WriteableBitmap image = new WriteableBitmap(
// sensor.ColorStream.FrameWidth,
// sensor.ColorStream.FrameHeight, 96, 96,
// PixelFormats.Bgra32, null);
colorFrame.CopyPixelDataTo(pixels);
colorImage.WritePixels(new Int32Rect(0, 0, colorImage.PixelWidth,
colorImage.PixelHeight),
pixels, colorImage.PixelWidth * 4, 0);
//BitmapSource image = BitmapSource.Create(colorFrame.Width, colorFrame.Height,
// 96, 96, PixelFormats.Bgr32, null,
// pixels, colorFrame.Width * 4);
//image.WritePixels(new Int32Rect(0, 0, image.PixelWidth, image.PixelHeight),
// pixels, image.PixelWidth * sizeof(int), 0);
//video.Source = image;
totalFrames++;
BitmapEncoder encoder = new JpegBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(colorImage));
//path = System.IO.Path.Combine("C:/", "Kinected", "Images");
if (PersonDetected == true)
{
if (totalFrames % 10 == 0)
{
if (file_name != null && colorImage != null)
{
try
{
using (FileStream fs = new FileStream(colorPath +
@"\Kinected Image " + time + ".jpg", FileMode.Create))
{
encoder.Save(fs);
}
}
catch (IOException)
{
System.Windows.MessageBox.Show("Save Failed");
}
}
}
skeletonDeLbl.Content = "Skeleton Detected!";
}
if (PersonDetected == false) skeletonDeLbl.Content = "No Skeleton Detected.";
}
저장
FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.Description = "Select which folder you want Kinected to keep all of its information/images in."; DialogResult result = dialog.ShowDialog(); colorPath = dialog.SelectedPath + @"\Color Images"; depthPath = dialog.SelectedPath + @"\Depth Images"; facePath = dialog.SelectedPath + @"\Face Data"; if (!Directory.Exists(colorPath)) Directory.CreateDirectory(colorPath); if (!Directory.Exists(depthPath)) Directory.CreateDirectory(depthPath); if (!Directory.Exists(facePath)) Directory.CreateDirectory(facePath); System.Windows.MessageBox.Show(colorPath);
편집
는 file_name
그냥 null입니다 밝혀,하지만 지금은 오류 때 무엇입니까 그것은 line using (FileStream fs = new FilesStream(file_name, FileMode.Create))
그 내용 :
An unhandled exception of type 'System.NotSupportedException' occurred in mscorlib.dll
Additional information: The given path's format is not supported.
왜 이런 일이 발생합니까? Microsoft의 데모와 똑같은 코드를 사용하고 있습니다. 감사.
"저장하지 않음"은 무엇을 의미합니까? 오류가 있습니까? 모든 파일 끝에는 파일이 없지만 잘 작동하는 것 같습니까? 파이 먹을 때 케이크 먹을거야? –
'PersonDetected && totalFrames % 10 == 0 && file_name! = null && colorImage! = null' 조건을 모두 만족합니까? 저장 코드가 전혀 실행되지 않습니까? 디버거를 사용하여 문제를 추적하십시오. –
@lc. 끝 부분에 파일이 없습니다. – Kinected