示例#1
0
    def test_mask_in_eight_connectivity(self):
        img = cv2.imread('penguin-img.png', 0)
        mask = cv2.imread('penguin-mask.png', 0)
        image = Image(img, mask, Connectivity.eight_connectivity)
        hole = image.hole

        assert len(hole.hole) == len(set(hole.hole))
        assert len(hole.hole) == 1215
        for p in hole.hole:
            assert 92 <= p[0] <= 106 and 13 <= p[1] <= 93

        assert len(hole.boundary) == len(set(hole.boundary))
        assert len(hole.boundary) == 196
        for p in hole.boundary:
            assert 91 <= p[0] <= 107 and p[1] in (12, 94) or 12 <= p[1] <= 94 and p[0] in (91, 107)
示例#2
0
    def __saveFrameImageToFile(self, frame):
        print "Pressed S (save image) button"

        #construct filepath where image will be saved
        dirpath = self.__folderStruct.getSavedFramesDirpath()
        imageFileName = frame.constructFilename()
        imageFilePath = dirpath + "/" + imageFileName

        #save image without any marks on it
        rawUncachedImage = Image(
            self.__videoStream.readFromVideoCapture(frame.getFrameID()))
        rawUncachedImage.drawFrameID(frame.getFrameID())

        print("Saving current frame to file: ", imageFilePath)
        rawUncachedImage.writeToFile(imageFilePath)
示例#3
0
 def Init_Images(self):
     self.images = []
     for q in range(self._param.sliceNum):
         self.images.append(Image(self._param.threshold,BLACK_FLAG))
示例#4
0
import cv2
from lib.Image import Image
from lib.Hole import Connectivity


mask = cv2.imread('penguin-mask.png', 0)
img = cv2.imread('penguin-img.png', 0)
a = Image(img, mask, Connectivity.four_connectivity)
a.hole.fix_hole()

cv2.namedWindow('image', cv2.WINDOW_NORMAL)
cv2.imshow('image', img)
cv2.waitKey(0)
cv2.destroyAllWindows()
示例#5
0
 def getImgObj(self):
     # type: () -> Image
     return Image(self.__videoStream.readImage(self.__frameID))
示例#6
0
 def readImageObj(self, frameID):
     # type: () -> Image
     return Image(self.readImage(frameID))