이것은 지금 사용하고있는 코드입니다.
private void words(string path)
{
List<string> text = new List<string>();
var intro = "Video File Name:";
var words = File.ReadAllLines(path)
.Where(line => line.StartsWith(intro))
.Select(line => line.Substring(intro.Length).Trim());
}
변수 경로는 텍스트 파일의 링크입니다. 다음은 텍스트 파일의 콘텐츠 형식입니다.
Video File Name: MVI_4523.MOV
Lightning Start Location At Frame: 11 Lightning End Location At Frame: 15
Lightning Start Location At Frame: 6 Lightning End Location At Frame: 15
Video File Name: MVI_4524.MOV
Lightning Start Location At Frame: 15 Lightning End Location At Frame: 19
Lightning Start Location At Frame: 4 Lightning End Location At Frame: 19
내가하고 싶은 것은 텍스트 파일의 모든 비디오 파일 이름 List<string>
을 예를 들어 목록 콘텐츠 로 구문 분석하는 것입니다.
색인 [0] MVI_4523.MOV
색인 [1] MVI_4524.MOV
그런 다음 List를 반복하고 각 인덱스를 내가 가진 변수와 비교하고 싶습니다. like string variable = videoFile
예를 들면 :
for (int i = 0; i < videosfilesnames.Length; i++)
{
if (videosfilesnames[i] == videoFile)
{
// Here I want to extract from the text file the lightnings values that are belong to the matched video file name for example if MVI_4524.MOV was == to videoFile so here i want to extract the values from the text file: 15 19 and 4 19
// Then in the end i need to create/draw point red point on the locations 15 to 19 and 4 to 19
// So when extracting the values I need to be able to know that 15 is start and 19 end.
}
}
여기서 추출해야하는 동영상 이름뿐만 아니라 모든 데이터입니다.
public class Lightening
{
public Lightening(int start, int end)
{
StartLocation = start;
EndLocation = end;
}
public int StartLocation { get; private set; }
public int EndLocation { get; private set; }
}
public class Video
{
public Video(string name)
{
Name = name;
Lightenings = new List<Lightening>();
}
public string Name { get; private set; }
public List<Lightening> Lightenings { get; private set; }
}
....
private List<Video> ExtractInfo(string path)
{
var videos = new List<Video>();
Video currentVideo = null;
using (var file = new System.IO.StreamReader(path))
{
string line;
Regex regex = new Regex(@"\d+");
while((line = file.ReadLine()) != null)
{
if (line.StartsWith("Video"))
{
currentVideo = new Video(line.Split(':')[1].Trim());
videos.Add(currentVideo);
}
else if (line.StartsWith("Lightning"))
{
var matches = regex.Matches(line);
if (matches.Count == 2 && currentVideo != null)
{
var l = new Lightening(Int32.Parse(matches[0].Value), Int32.Parse(matches[1].Value));
currentVideo.Lightenings.Add(l);
}
}
}
}
return videos;
}
이것은 렌더링에 필요한 모든 정보를 제공합니다.
for (int i = 0; i < videos.Count; i++)
{
if (videos[i].Name == videoFile)
{
foreach (var l in videos[i].Lightenings)
{
// draw from l.StartLocation to l.EndLocation
}
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다