Opencv programming

that’s the problem. since you are a beginner to programming, and the problem is fundamental programming (loops, variables), you should find a forum that is intended for general programming questions. this forum is specific to OpenCV issues and basic programming proficiency is expected.