그래서 사전에 데이터를 넣을 것입니다. 문자열 (이름)과 뼈 (위치와 물건을 잡는 데 사용됨). 나는 뼈의 위치가 무엇인지를 kinect에서 읽은 다음 사전에 넣고 나중에 .txt 파일에 저장합니다. 이제 나는 모두가 동일하기 때문에 꽤 혼란 스럽다. 잠시 동안 나는 몇 개의 뼈의 다른 위치를 보여주는 몇 개의 레이블을 가지고 있으며, 그들은 모두 변화하고 있었다. 그럼 그건 사전에 넣는 것과 관련이 있다는 뜻인가요?사전에 다른 입력이 모두 동일하게 나와 있습니다.
JointCollection joints = skele.Joints;
List<Bone> temp = current_bones;
Frame temp_f = new Frame(temp);
Joint h_j = joints[JointType.Head];
foreach (Joint j in joints)
{
try
{
switch (j.JointType)
{
#region cases
case (JointType.Head):
temp_f.frame_bones["Head"].setPosition(j.Position.X, j.Position.Y, j.Position.Z);
break;
...Other stuff that basically repeats but with different jointtypes
}
}
catch (Exception ex) { /*MessageBox.Show("Error getting joints: " + ex.Message);*/ }
}
if (recording)
{
if (newR)
{
bvhBuilder.resetAnimation(); //Resets a list of frames
newR = false;
}
bvhBuilder.add_frame(temp_f);//adds a frame to the list
}
뼈 클래스의
주요 재료 : 내 BVHBuilder 클래스의
public Bone(String b_name)
{
name = b_name;
}
public void setPosition(float _x, float _y, float _z)
{
x = _x; y = _y; z = _z;
}
와 관계있는 물건 :
List<Bone> current_bones = new List<Bone>();
Frame current_frame;
List<Frame> animation_frames = new List<Frame>();
public BVHBuilder(List<Bone> bones)
{
current_bones = bones;
}
public String build()
{
StringBuilder builder = new StringBuilder();
builder.AppendLine(build_bones());
builder.AppendLine(build_anim());
return builder.ToString();
}
public String build_anim()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("MOTION");
sb.AppendLine("Frames: " + getFrameCount());
sb.AppendLine("Frame Time: " + (float)((float)1/(float)30));
foreach (Frame frame in animation_frames)
{
String line = "";
int b_i = 0;
float root_x = frame.root.x;
float root_y = frame.root.y;
float root_z = frame.root.z;
Console.WriteLine("Root: (" + root_x + "," + root_y + "," + root_z + ")");
for (int i = 0; i < frame.frame_bones.Count; i++)
{
Bone bone = frame.frame_bones.Values.ElementAt(i);
line += (bone.x - root_x) + " ";
line += (bone.y - root_y) + " ";
if (b_i >= frame.frame_bones.Count) { line += (root_z - bone.z); } //Don't want a space at the end
else { line += (root_z - bone.z) + " "; }
b_i++;
}
sb.AppendLine(line);
}
return sb.ToString();
}
프레임 클래스 :
다음 내 입력 방법class Frame
{
public Dictionary<String, Bone> frame_bones = new Dictionary<String, Bone>();
public Bone root = null;
int root_pos = 0;
public Frame(List<Bone> bones)
{
int i = 0;
foreach (Bone b in bones)
{
frame_bones.Add(b.name,b);
if (b.root) { root_pos = i; root = b; }
i++;
}
}
}
이 저장 위치를 17,451,515,
는 그리고 이것은이다 :
private void saveAnim()
{
int times = 0;
String path = "";
Boolean exists = true;
while (exists)
{
path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\" + "nectrecord" + times + ".txt";
exists = File.Exists(path);
times++;
}
currP = path;
Console.WriteLine(currP);
StreamWriter sw = new StreamWriter(currP);
String write = bvhBuilder.build();
int max_i = write.Length;
progressBar1.Maximum = max_i;
int c_i = 0;
foreach (char c in write)
{
sw.Write(c);
c_i++;
progressBar1.Value = c_i;
}
sw.Flush();//make sure everything wrote
sw.Close();
MessageBox.Show("Saved to :" + currP);
}
난 그 코드를 많이 알지만, 지금은 아마 4 시간이 디버깅을 시도하고있다. 다행히도 새로운 눈 쌍이 문제를 찾는데 도움이 될 것입니다.
는 Btw는이 출력 파일의 모습입니다 :
HIERARCHY
ROOT Hip_C
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Spine
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Shoulder_C
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Head
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
}
JOINT Shoulder_R
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Elbow_R
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Wrist_R
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Hand_R
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
}
}
}
}
JOINT Shoulder_L
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Elbow_L
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Wrist_L
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Hand_L
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
}
}
}
}
}
}
JOINT Hip_R
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Knee_R
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Ankle_R
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Foot_R
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
}
}
}
}
JOINT Hip_L
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Knee_L
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Ankle_L
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
JOINT Foot_L
{
OFFSET 0 0 0
CHANNELS 3 Xposition Yposition Zposition
}
}
}
}
}
MOTION
Frames: 210
Frame Time: 0.03333334
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.05713073 -0.009174455 -0.2937571 0.2087359 -0.2028138 -0.902887 0.2087359 -0.2028138 -0.9028869 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
... 그리고 그
이것은 내가 본 가장 긴 질문입니다. –
나는 그것을 알고있다. xD를 구할 다른 방법이 없다. – Brandon