Ejemplo n.º 1
0
            ans.append(anss)
        print("Correct option of each questions are", ans)
        grading = []
        for x in range(0, questions):
            if ans[x] == myIndex[x]:
                grading.append(1)
            else:
                grading.append(0)
        # print("GRADING",grading)
        score = (sum(grading) / questions) * 100  # FINAL GRADE
        # print("SCORE",score)

        # DISPLAYING ANSWER

        imgResult=imgWrapColored.copy()
        imgResult=utlis.showAnswers(imgResult,myIndex,grading,ans,questions,choices)   # DRAW DETECTED ANSWERS

        imgRawDrawing = np.zeros_like(imgWrapColored)  # NEW BLANK IMAGE WITH WARP IMAGE SIZE
        imgRawDrawing = utlis.showAnswers(imgRawDrawing, myIndex, grading, ans, questions, choices)  # DRAW ON NEW IMAGE

        invMatrix = cv2.getPerspectiveTransform(pt2, pt1)   # INVERSE TRANSFORMATION MATRIX
        imgInvWrap = cv2.warpPerspective(imgRawDrawing, invMatrix, (widthImg, heightImg))    # INV IMAGE WARP

        # DISPLAY GRADE
        imgRawGrade = np.zeros_like(imgGardeDisplay, np.uint8)  # NEW BLANK IMAGE WITH GRADE AREA SIZE
        cv2.putText(imgRawGrade, str(int(score)) + "%", (70, 100)
                        , cv2.FONT_HERSHEY_COMPLEX, 3, (0, 255, 255), 3)  # ADD THE GRADE TO NEW IMAGE
        invMatrixG = cv2.getPerspectiveTransform(ptG2, ptG1)  # INVERSE TRANSFORMATION MATRIX
        imgInvGradeDisplay = cv2.warpPerspective(imgRawGrade, invMatrixG, (widthImg, heightImg))  # INV IMAGE WARP

        imgFinal=cv2.addWeighted(imgFinal,1,imgInvWrap,1,0)
Ejemplo n.º 2
0
                myIndexVal = np.where(arr == np.amax(arr))
                myIndex.append(myIndexVal)

            # Compare the value to find the correct ones
            grading = []

            for x in range(0, questions):
                if ans[x] == myIndex[x]:
                    grading.append(1)
                else:
                    grading.append(0)

            score = (sum(grading) / questions) * 100

            # Dispaly answers
            utlis.showAnswers(imgWarpColored, myIndex, grading, ans)
            utlis.drawGrid(imgWarpColored)
            # New blank image with the size of the warpped image
            imgRawDrawings = np.zeros_like(imgWarpColored)
            utlis.showAnswers(imgRawDrawings, myIndex, grading, ans)
            # Inverse the transformation matrix
            invMatrix = cv2.getPerspectiveTransform(pts2, pts1)
            imgInvWarp = cv2.warpPerspective(imgRawDrawings, invMatrix,
                                             (widthImg, heightImg))

            # Display grade
            imgRawGrade = np.zeros_like(imgGradeDisplay, np.uint8)
            cv2.putText(imgRawGrade,
                        str(int(score)) + "%", (70, 100),
                        cv2.FONT_HERSHEY_COMPLEX, 3, (0, 255, 255), 3)
            invGradeMatrix = cv2.getPerspectiveTransform(ptsG2, ptsG1)
Ejemplo n.º 3
0
                myIndex.append(myIndexVal[0][0])
            #print("USER ANSWERS",myIndex)

            # COMPARE THE VALUES TO FIND THE CORRECT ANSWERS
            grading = []
            for x in range(0, questions):
                if ans[x] == myIndex[x]:
                    grading.append(1)
                else:
                    grading.append(0)
            #print("GRADING",grading)
            score = (sum(grading) / questions) * 100  # FINAL GRADE
            #print("SCORE",score)

            # DISPLAYING ANSWERS
            utlis.showAnswers(imgWarpColored, myIndex, grading,
                              ans)  # DRAW DETECTED ANSWERS
            utlis.drawGrid(imgWarpColored)  # DRAW GRID
            imgRawDrawings = np.zeros_like(
                imgWarpColored)  # NEW BLANK IMAGE WITH WARP IMAGE SIZE
            utlis.showAnswers(imgRawDrawings, myIndex, grading,
                              ans)  # DRAW ON NEW IMAGE
            invMatrix = cv2.getPerspectiveTransform(
                pts2, pts1)  # INVERSE TRANSFORMATION MATRIX
            imgInvWarp = cv2.warpPerspective(
                imgRawDrawings, invMatrix,
                (widthImg, heightImg))  # INV IMAGE WARP

            # DISPLAY GRADE
            imgRawGrade = np.zeros_like(
                imgGradeDisplay,
                np.uint8)  # NEW BLANK IMAGE WITH GRADE AREA SIZE
Ejemplo n.º 4
0
            # GRADING
            grading = []
            for x in range(0, question):
                if ans[x] == myIndex[x]:
                    grading.append(1)
                else:
                    grading.append(0)
            #print(grading)

            score = (sum(grading) / question) * 100  # FINAL GRADE
            print(score)

            # SHOW ANSWERS
            ImgResult = ImgWarpColored.copy()
            ImgResult = utlis.showAnswers(ImgResult, myIndex, grading, ans,
                                          question, choise)
            ImgDrawing = np.zeros_like(ImgWarpColored)
            ImgDrawing = utlis.showAnswers(ImgDrawing, myIndex, grading, ans,
                                           question, choise)
            InvMatrix = cv2.getPerspectiveTransform(pt2, pt1)
            ImgInvWarp = cv2.warpPerspective(ImgDrawing, InvMatrix,
                                             (widthImg, heightImg))

            ImgRawGrade = np.zeros_like(ImgGradeDisplay)
            cv2.putText(ImgRawGrade,
                        str(int(score)) + "%", (50, 100),
                        cv2.FONT_HERSHEY_COMPLEX, 3, (0, 100, 255), 3)
            #cv2.imshow("Grade Image",ImgRawGrade)
            InvMatrixG = cv2.getPerspectiveTransform(ptG2, ptG1)
            ImgInvGradeDisplay = cv2.warpPerspective(ImgRawGrade, InvMatrixG,
                                                     (widthImg, heightImg))