コード例 #1
0
    # pre_proc = Cards.preprocces_image(frame)

    subimagelist = extractimages.getimages(frame)

    k = 0
    width, height, channel = frame.shape
    for i in range(len(subimagelist)):
        # Find contour for kort stakken i billedet.
        # subimage = getattr(image, 'img')
        # cv2.imshow('hej', subimagelist[i])
        pre_proc = Cards.preprocces_image(subimagelist[i], i)
        cnts_sort, cnt_is_card, crns = Cards.find_cards(pre_proc)

        if len(crns) != 0:

            w, h, top1, top2, bot1, bot2 = Cards.CalculateCardPosition(
                crns, subimagelist[i], oldintersections[i])
            oldintersections[i][0] = bot1
            oldintersections[i][1] = bot2
            crns = [bot1, bot2, top1, top2]
            # cv2.circle(frame, (int(top1[0]), int(top1[1])), 6, (0, 255, 255), -1)
            # cv2.circle(frame, (int(top2[0]), int(top2[1])), 6, (0, 255, 255), -1)
            # cv2.circle(frame, (int(bot1[0]), int(bot1[1])), 6, (0, 0, 255), -1)
            # cv2.circle(frame, (int(bot2[0]), int(bot2[1])), 6, (0, 0, 255), -1)
            cards[k] = Cards.preprocess_card(subimagelist[i], crns, w, h,
                                             cards[k])

            cards[k].best_rank_match, cards[k].best_suit_match, cards[k].rank_diff, \
            cards[k].suit_diff = Cards.match_card(cards[k], train_ranks, train_suits)

            # Draw center point and match result on the image.
            # Vi bliver nødt til at shifte vores koordinater. De koordinater der kommer ud af vores cropped billeder