Autor Beitrag
Sunny9019
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 09.01.12 20:41 
hallo alle zusammen

ich bin neu hier, und habe probleme damit, Daten aus einer List"Frame" auszulesen und abzuspeichern...

ich habe mal angefangen ein array zu schreiben, welches die daten übernehmen soll
es soll mir dann die Koordinaten X;Y;Z ausgeben....

wenn sich jemand damit auskennt, wäre es mir eine sehr große hilfe!!!! ich kann euch ja mein bisheriges programm per mail schicken.... bzw dann hier raufladen...

bedanke mich schon mal im vorraus

mfg

Moderiert von user profile iconTh69: Titel geändert: Ausrufezeichen entfernt
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19338
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mo 09.01.12 21:48 
Hallo und :welcome:

user profile iconSunny9019 hat folgendes geschrieben Zum zitierten Posting springen:
ich bin neu hier, und habe probleme damit, Daten aus einer List"Frame" auszulesen und abzuspeichern...
Darunter kann ich mir erst einmal relativ wenig vorstellen. ;-)
Vor allem auch wo du dabei ein Problem hast.

Deshalb ist das eine gute Idee: ;-)
user profile iconSunny9019 hat folgendes geschrieben Zum zitierten Posting springen:
ich kann euch ja mein bisheriges programm per mail schicken.... bzw dann hier raufladen...
Sunny9019 Threadstarter
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 09.01.12 22:15 
hehe, damit meinte ich neu in der C# welt ;)

also, es geht um die kinect, daten werden asugelesen und sollen abgespeichert werden - und die text datei soll mir dann die koordinaten ausgeben!

das problem ich, dass ich nicht weiß, wie man aus einer List daten in eine textdatei abspeichern kann, und diese dann nur koordinaten ausgibt:
ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Research.Kinect.Nui;
using Microsoft.Xna.Framework;

namespace KiMotion
{
    public class KMMovement
    {

        List<KMFrame> frames;
        List<KMMotion> motions;
        List<KMMotionDiff> motionDiffs;
        KMOptions options;
        int totalTime;
        int totalFrames;

        public KMMovement(KMOptions options)
        {
            frames = new List<KMFrame>();
            motions = new List<KMMotion>();
            motionDiffs = new List<KMMotionDiff>();
            this.options = options;
            totalTime = 0;
            totalFrames = 0;
        }

        public void addFrame(SkeletonData skeletonData, int timeElapsed)
        {
            frames.Add(new KMFrame(skeletonData, timeElapsed, options.KMSKELETON));
            totalFrames++;
            totalTime += timeElapsed;

            if (totalFrames > 1)
            {
                motions.Add(new KMMotion(frames[totalFrames - 1], frames[totalFrames], options.KMSKELETON.Achsen, options.MAXJOINTS, options.ZEITANPASSUNG));
            }
            if (totalFrames > 2)
            {
                motionDiffs.Add(new KMMotionDiff(motions[totalFrames - 2], motions[totalFrames - 1], timeElapsed, options.ZEITANPASSUNG));
            }
        }

        public KMFrame getFrame(int frame)
        {
            return frames[frame];
        }

        public int TotalFrames
        {
            get
            {
                return totalFrames;
            }
        }

        public int TotalTime
        {
            get
            {
                return totalTime;
            }
        }


    }
}


void saveMovement(string filename)
        {
            using (StreamWriter sw = new StreamWriter(filename))
            {
                // Add some text to the file.
                for (int i = 0; i < frames.Count; i++)
                {
                    for (int j = 0; j < options.MAXJOINTS; j++)
                    {
                        sw.Write(frames[i].Gelenke[j].X) + "\t";
                        sw.Write(frames[i].Gelenke[j].Y);
                        sw.Write(frames[i].Gelenke[j].Z);
                        sw.Write(frames[i].TimeElapsed);
                    }
                }
                sw.Write(frames[0].Gelenke[0].X);
                sw.WriteLine("header for the file.");
                sw.WriteLine("-------------------");
                // Arbitrary objects can also be written to the file.
                sw.Write("The date is: ");
                sw.WriteLine(DateTime.Now);
            }
        }


MEINE IDEE WÄRE FOLGENDE: (wobei ich mir da aber auch nicht wirklich sicher bin!!!)



        private const string SafeData = "SafeData.txt";             // text datei erstellen
        public static void Main(String[] args)
        {
            if (File.Exists(SafeData))
            {
                Console.WriteLine("{0} already exists.", SafeData);
                return;
            }
            using (StreamWriter sw = File.CreateText(SafeData))
            {
                sw.WriteLine("Folgendes wird gespeichert");
                sw.WriteLine("{0};{1};{2}", X, Y, Z);
                sw.Close();
            }
        }



        public class TextToFile                             // totalTimes in SafeData schreiben
        {
            private const string SafeData = "SafeData.txt";
            public static void Main(String[] args)
            {
                if (File.Exists(SafeData))
                {
                    Console.WriteLine("{0} already exists.", totalTime);
                    return;
                }
                using (StreamWriter sw = File.CreateText(SafeData))
                {
                    sw.WriteLine("The total Time is");
                    sw.WriteLine("{0}; {1}, and so on.",totalTime);
                    sw.Close();
                }
            }
        }


        private const string SafeData = "SafeData.txt";         // totalFrames in SafeData schreiben
        public static void Main(String[] args)
        {
            if (File.Exists(totalFrames))
            {
                Console.WriteLine("{0} already exists.", totalFrames);
                return;
            }
            using (StreamWriter sw = File.CreateText(SafeData))
            {
                sw.WriteLine(".....");
                sw.WriteLine(".... {0} .... {1}",totalFrames);
                sw.Close();
            }
        }



        
        private const string SafeData = "SafeData.txt";         // saveMovement in SafeData schreiben = Koordinaten
        public static void Main(String[] args)
        {
            if (File.Exists(saveMovement))
            {
                Console.WriteLine("{0} already exists.", saveMovements);
                return;
            }
            using (StreamWriter sw = File.CreateText(SafeData))
            {
                sw.WriteLine("{0};{1};{2}", saveMovement);
                sw.WriteLine("{0};{1};{2}", X, Y, Z);
                sw.Close();
            }
        }


        private const string SafeData = "SafeData.txt";         // Lesen aus einer Textdatei
        public static void Main(String[] args)
        {
            if (!File.Exists(SafeData))
            {
                Console.WriteLine("{0} does not exist.", SafeData);
                return;
            }
            using (StreamReader sr = File.OpenText(SafeData))
            {
                String input;
                while ((input = sr.ReadLine()) != null)
                {
                    Console.WriteLine(input);
                }
                Console.WriteLine("The end of the stream has been reached.");
                sr.Close();
            }
        }


Moderiert von user profile iconTh69: C#-Tags hinzugefügt
Sunny9019 Threadstarter
Hält's aus hier
Beiträge: 3



BeitragVerfasst: Mo 09.01.12 22:24 
ich möchte dass totalTime und totalFrames in eine datei gespeichert werden, in diesen ints werden alle koordinaten und daten gespeichert!

und ich möchte dass koordinaten X;Y;Z; ausgegeben werden...