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

Merged cpp and python modules, finished dynamic binary of timestamp generator;...

Merged cpp and python modules, finished dynamic binary of timestamp generator; can be called with video file as argument. Need to stitch together with other parts for functioning MVP.
parent 5c3eb3d0
No related branches found
No related tags found
No related merge requests found
{ {
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cmake.sourceDirectory": "${workspaceFolder}/openCV", "cmake.sourceDirectory": "${workspaceFolder}/src/openCV",
"files.associations": { "files.associations": {
"*.t": "cpp" "*.t": "cpp"
} }
......
...@@ -13,6 +13,15 @@ ...@@ -13,6 +13,15 @@
using namespace std; using namespace std;
using namespace cv; using namespace cv;
void csvCreater(string filename){
}
void csvWriter(){
}
// 2^-11 // 2^-11
double percentChangeThreshold = 0.00048828125; double percentChangeThreshold = 0.00048828125;
...@@ -38,7 +47,7 @@ bool detectChange(Mat firstFrame, Mat secFrame) { ...@@ -38,7 +47,7 @@ bool detectChange(Mat firstFrame, Mat secFrame) {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
/*if (argc != 2) { if (argc != 2) {
cerr << "Can only pass 1 argument as input."; cerr << "Can only pass 1 argument as input.";
cerr << endl; cerr << endl;
return -1; return -1;
...@@ -49,10 +58,10 @@ int main(int argc, char** argv) { ...@@ -49,10 +58,10 @@ int main(int argc, char** argv) {
cerr << "Failed to read input; make sure it is a valid .mp4 video file." << endl; cerr << "Failed to read input; make sure it is a valid .mp4 video file." << endl;
cerr << "Current input: " << argv[1]; cerr << "Current input: " << argv[1];
return -1; return -1;
}*/ }
// Currently using Myggbukta-[2021-05-21_10-47-06]-716 as test.mp4. // Currently using Myggbukta-[2021-05-21_10-47-06]-716 as test.mp4.
VideoCapture decoder("test.mp4"); VideoCapture decoder(videoPath.string());
auto start = chrono::steady_clock::now(); auto start = chrono::steady_clock::now();
int detectionsPerSec = 3; int detectionsPerSec = 3;
...@@ -82,6 +91,7 @@ int main(int argc, char** argv) { ...@@ -82,6 +91,7 @@ int main(int argc, char** argv) {
Mat binaryNextFrame; Mat binaryNextFrame;
Mat medianBlurFrame; Mat medianBlurFrame;
Mat medianBlurNextFrame; Mat medianBlurNextFrame;
int blurRadius = 5;
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);
...@@ -103,8 +113,8 @@ int main(int argc, char** argv) { ...@@ -103,8 +113,8 @@ int main(int argc, char** argv) {
p_bgSub->apply(nextFrame, binaryNextFrame, -1); p_bgSub->apply(nextFrame, binaryNextFrame, -1);
// Code runs 30min input file in ~9 minutes. Reducing this median blur value from 7 -> 5, yields run time of ~2 minutes, but more noisy output. // Code runs 30min input file in ~9 minutes. Reducing this median blur value from 7 -> 5, yields run time of ~2 minutes, but more noisy output.
medianBlur(binaryFrame, medianBlurFrame, 7); medianBlur(binaryFrame, medianBlurFrame, blurRadius);
medianBlur(binaryNextFrame, medianBlurNextFrame, 7); medianBlur(binaryNextFrame, medianBlurNextFrame, blurRadius);
motionVec.push_back(detectChange(medianBlurFrame, medianBlurNextFrame)); motionVec.push_back(detectChange(medianBlurFrame, medianBlurNextFrame));
......
import subprocess as sp
import os
def main():
curDir = os.getcwd()
repoRootToBinary = "build\\Release\\opencvtest.exe"
pathToBinary = os.path.join(curDir, repoRootToBinary)
prog = sp.Popen(['runas', '/noprofile', '/user:Administrator', pathToBinary],stdin=sp.PIPE)
prog.stdin.write('')
prog.communicate()
main()
\ No newline at end of file
...@@ -46,13 +46,12 @@ def trim(inputVideo, csvTimestamps): ...@@ -46,13 +46,12 @@ def trim(inputVideo, csvTimestamps):
) )
def main(): def readForCSV():
# Changes working directory to the specified path. CHANGE DURING STANDALONE BUILD. # Changes working directory to the specified path. CHANGE DURING STANDALONE BUILD.
os.chdir("gitlab repo/nina-thesis") os.chdir("gitlab repo/nina-thesis")
if "trimmed" not in os.listdir(): if "trimmed" not in os.listdir():
os.mkdir("trimmed") os.mkdir("trimmed")
while(True):
for file in os.listdir(): for file in os.listdir():
if file.endswith(".csv"): if file.endswith(".csv"):
with open(file) as csvFile: with open(file) as csvFile:
...@@ -60,8 +59,5 @@ def main(): ...@@ -60,8 +59,5 @@ def main():
for row in reader: for row in reader:
logging.getLogger().info("Trimming file %s" % row[0]) logging.getLogger().info("Trimming file %s" % row[0])
trim(row[0], row[1:]) trim(row[0], row[1:])
sleep(900)
if __name__ == "__main__":
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment