diff --git a/OpenCVVideoParser/main.cpp b/OpenCVVideoParser/main.cpp index 767c6a7..6b62b8e 100644 --- a/OpenCVVideoParser/main.cpp +++ b/OpenCVVideoParser/main.cpp @@ -83,15 +83,50 @@ public: float frameView=0; cv::VideoCapture video; // open the video file bool edgeDetect=true; - float edgeLowerThreshold=150; + float edgeLowerThreshold=200; float edgeUpperThreshold=255; + int overallDensity=0; + int overallPixelCount=0; + int leftDensity=0; + int leftPixelCount=0; + int rightDensity=0; + int rightPixelCount=0; + int lowerLeftDensity=0; + int lowerLeftPixelCount=0; + int upperLeftDensity=0; + int upperLeftPixelCount=0; + int lowerRightDensity=0; + int lowerRightPixelCount=0; + int upperRightDensity=0; + int upperRightPixelCount=0; bool OnUserCreate() override { // Called once at the start, so create things here - video.open("C:/users/sigon/Videos/test.mp4"); + video.open("C:/users/sigon/Videos/C0046.MP4"); return true; } + void RenderScreenPortions(vf2d pos,vf2d size,bool debug=false){ + FillRectDecal(pos,size,{255,255,255,64}); + FillRectDecal(pos,{size.x/2,size.y},{255,0,0,64}); + FillRectDecal(pos+vf2d{size.x/2,0},{size.x/2,size.y},{0,0,255,64}); + FillRectDecal(pos,size/2,{255,0,0,64}); + FillRectDecal(pos+vf2d{size.x/2,0},size/2,{0,0,255,64}); + FillRectDecal(pos+vf2d{0,size.y/2},size/2,{255,255,0,64}); + FillRectDecal(pos+size/2,size/2,{0,255,0,64}); + vf2d fontSize={2,2}; + DrawStringDecal(pos+vf2d{1,1},std::to_string(upperLeftPixelCount)+"/"+std::to_string(upperLeftDensity),WHITE,fontSize); + DrawStringDecal(pos+vf2d{size.x/2+1,1},std::to_string(upperRightPixelCount)+"/"+std::to_string(upperRightDensity),WHITE,fontSize); + DrawStringDecal(pos+vf2d{1,size.y/2+1},std::to_string(lowerLeftPixelCount)+"/"+std::to_string(lowerLeftDensity),WHITE,fontSize); + DrawStringDecal(pos+size/2+vf2d{1,1},std::to_string(lowerRightPixelCount)+"/"+std::to_string(lowerRightDensity),WHITE,fontSize); + std::string leftDisplayStr=std::to_string(leftPixelCount)+"/"+std::to_string(leftDensity); + DrawStringDecal(pos+vf2d{1+size.x/4,1+size.y+16}-GetTextSize(leftDisplayStr)*fontSize/2,leftDisplayStr,WHITE,fontSize); + std::string rightDisplayStr=std::to_string(rightPixelCount)+"/"+std::to_string(rightDensity); + DrawStringDecal(pos+vf2d{1+size.x*0.75f,1+size.y+16}-GetTextSize(rightDisplayStr)*fontSize/2,rightDisplayStr,WHITE,fontSize); + std::string centerDisplayStr=std::to_string(overallPixelCount)+"/"+std::to_string(overallDensity); + DrawStringDecal(pos+vf2d{1+size.x/2,1+size.y+48}-GetTextSize(centerDisplayStr)*fontSize/2,centerDisplayStr,WHITE,fontSize); + } + void UpdateScreen(){ Clear(BLACK); cv::Mat targetFrame=get_frame(video,std::clamp(int(frameView),0,int(video.get(cv::CAP_PROP_FRAME_COUNT)))); @@ -137,7 +172,7 @@ public: } if(!cabDetected){ DrawString({4,ScreenHeight()-40},"Drag over the region where the cab's screen is located.\n (Make sure the entire cabinet screen is covered)",WHITE,2); - FillRectDecal(upperLeft,lowerRight-upperLeft,{255,255,255,128}); + RenderScreenPortions(upperLeft,lowerRight-upperLeft,true); DrawString({4,ScreenHeight()-40-16},"Upper Threshold: "+std::to_string(edgeUpperThreshold),WHITE,2); DrawString({4,ScreenHeight()-40-32},"Lower Threshold: "+std::to_string(edgeLowerThreshold),WHITE,2); }