mabrao / Tennis-Training-System

The goal of this project is to create a mobile application that will use computer vision and possibly a hardware mount for a tennis racket to help a tennis player improve their technique and game plan.
3 stars 0 forks source link

Main Page and Analysis Page reusable design #7

Open mabrao opened 2 years ago

mabrao commented 2 years ago

The main page and analysis page turned out to be similar. It would be good to create a reusable function that could be called within those two pages just using different parameters. This would make the design of the project cleaner and the code easier to understand. This function would be called inside the update method of both analysis page and main page classes. It would adapt the following block of code for use in both classes:

if self.pose: 
            try:
                #find pose landmarks and do not draw them
                self.frame = self.detector.findPose(self.frame, draw=False)
                #get all landmark data and do not draw bounding box
                lmList, bboxInfo = self.detector.findPosition(self.frame, draw = False) 
                #create customized figure
                self.detector.drawCustomizedFigure(self.frame, self.lmDraw, drawRacket=False)
            except:
                pass

        if self.poseBackground:
            width, height = self.get_dims()
            self.blankImg = np.zeros((height, width, 3), np.uint8)
            if self.pose:
                try:
                    #find pose landmarks and do not draw them
                    self.frame = self.detector.findPose(self.frame, draw=False)
                    #get all landmark data and do not draw bounding box
                    lmList, bboxInfo = self.detector.findPosition(self.frame, draw = False) 
                    #create customized figure
                    self.detector.drawCustomizedFigure(self.frame, self.lmDraw, drawRacket=False, blankImg = self.blankImg, drawExtra=True)
                except:
                    pass
            self.frame = self.blankImg