Skip to content
Snippets Groups Projects
Commit 10445fd2 authored by Leonardo de Lima Gaspar's avatar Leonardo de Lima Gaspar
Browse files

Fixed .csv reading, now correctly finds ground truth in input folder if it...

Fixed .csv reading, now correctly finds ground truth in input folder if it exists. Changed notation to 'groundTruth_[file]'
parent 187950d1
No related branches found
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ ofstream createCSV(filesystem::path videoFilePath); ...@@ -20,7 +20,7 @@ ofstream createCSV(filesystem::path videoFilePath);
// and returns true for when the ratio of the sum of those changes is sufficiently large. // and returns true for when the ratio of the sum of those changes is sufficiently large.
bool detectChange(Mat firstFrame, Mat secFrame); bool detectChange(Mat firstFrame, Mat secFrame);
double percentChangeThreshold = 0.001; double percentChangeThreshold = 0.00001;
int main(int argc, char** argv) { int main(int argc, char** argv) {
if (argc != 2) { if (argc != 2) {
...@@ -41,7 +41,7 @@ int main(int argc, char** argv) { ...@@ -41,7 +41,7 @@ int main(int argc, char** argv) {
VideoCapture decoder(videoPath.string()); VideoCapture decoder(videoPath.string());
auto start = chrono::steady_clock::now(); auto start = chrono::steady_clock::now();
int detectionsPerSec = 3; int detectionsPerSec = 2;
// Amount of extra time each detection interval will be padded with. // Amount of extra time each detection interval will be padded with.
double paddingTime_s = 1; double paddingTime_s = 1;
...@@ -66,7 +66,7 @@ int main(int argc, char** argv) { ...@@ -66,7 +66,7 @@ int main(int argc, char** argv) {
Mat binaryNextFrame; Mat binaryNextFrame;
Mat medianBlurFrame; Mat medianBlurFrame;
Mat medianBlurNextFrame; Mat medianBlurNextFrame;
int blurRadius = 5; int blurRadius = 9;
int32_t height = decoder.get(CAP_PROP_FRAME_HEIGHT); int32_t height = decoder.get(CAP_PROP_FRAME_HEIGHT);
int32_t width = decoder.get(CAP_PROP_FRAME_WIDTH); int32_t width = decoder.get(CAP_PROP_FRAME_WIDTH);
......
...@@ -27,7 +27,7 @@ def main(inputVideo): ...@@ -27,7 +27,7 @@ def main(inputVideo):
print("No input folder found. Creating it now. Place input video files in that folder.") print("No input folder found. Creating it now. Place input video files in that folder.")
return return
print("Processing file {file}".format(file=inputVideo)) print("Processing file {file}".format(file=inputVideo))
#os.system("opencvtest.exe {input}".format(input="input/{file}".format(file=inputVideo))) os.system("opencvtest.exe {input}".format(input="input/{file}".format(file=inputVideo)))
prefix, ext = os.path.splitext(inputVideo) prefix, ext = os.path.splitext(inputVideo)
print("\nVideo processed and outputted to {csv}.".format(csv=prefix+".csv")) print("\nVideo processed and outputted to {csv}.".format(csv=prefix+".csv"))
......
...@@ -49,20 +49,23 @@ def doesGroundTruthExist(groundTruthInput): ...@@ -49,20 +49,23 @@ def doesGroundTruthExist(groundTruthInput):
for file in os.listdir(): for file in os.listdir():
if file == groundTruthInput: if file == groundTruthInput:
return True return True
else:
return False return False
def readForCSV(inputVideoName): def readForCSV(inputVideoName):
inputNoExt = os.path.splitext(inputVideoName)[0]
os.chdir("input") os.chdir("input")
if inputVideoName in os.listdir(): if inputVideoName in os.listdir():
# Checks if there is a .csv in the directory. If there is, tries to trim according to timestamps. # Checks if there is a .csv in the directory. If there is, tries to trim according to timestamps.
# Expects even-sized appropriately timed timestamps in seconds of the input video. # Expects even-sized appropriately timed timestamps in seconds of the input video.
# Example: {5, 33, 106, 180} -> Two intervals of length 28 and 74 seconds respectively. # Example: {5, 33, 106, 180} -> Two intervals of length 28 and 74 seconds respectively.
videoFound = False videoFound = False
groundTruthName = "groundTruth" + os.path.splitext(inputVideoName)[0] + ".csv" groundTruthName = "groundTruth_" + inputNoExt + ".csv"
for file in os.listdir(): for file in os.listdir():
if file != groundTruthName and file.endswith(".csv"): if os.path.splitext(file)[0] == inputNoExt and file.endswith(".csv"):
videoFound = True videoFound = True
print(".csv file with same name as input video found")
with open(file) as csvFile: with open(file) as csvFile:
reader = csv.reader(csvFile, delimiter=",") reader = csv.reader(csvFile, delimiter=",")
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment