コード例 #1
0
def main():
    #if(len(sys.argv) != 3):
    #    raise Exception("Expected 3 arguments; got {}\nExpected format is ~.py /path/to/coordinates.txt /path/to/image.jpg".format(len(sys.argv)))

    #coordPath = sys.argv[1]
    #imagePath = sys.argv[2]
    coordPath = 'coords2.txt'
    imagePath = 'Videos/Parking2.jpg'
    """
    TODO:
        Open file and loop through it taking 4 coords at a time putting it in a [][4]
        Crop given image to each coord space, save it, and give that path to the detect_image
        If it sees 0, add one to a count
    """
    availableSpots = 0

    coordFile = open(coordPath, "r")
    file = coordFile.read().split("\n")
    for line in file:
        lineSplit = line.split(",")
        croppedPath = cropImage(imagePath, lineSplit)

        result = detect_image(croppedPath)
        if (result == 0):
            availableSpots += 1

    print("There are", availableSpots, "available spots open")
コード例 #2
0
def addValuesToDB(img, database):
    fileLocation = "DB/DB" + str(database) + ".txt"
    print(fileLocation)
    f = open(fileLocation, "a")
    #apply thining croping and scaling then get feature vector and store it
    imgStore = scaleImage(cropImage(thining(img)), 100, 100)
    temp = str(getFeatureVector(imgStore)) + '\n'
    f.write(temp)
    f.close()
コード例 #3
0
def conectCharScale(imgs, width, height):
    cols = imgs[0].height
    rows = imgs[0].width
    newImage = Image.new("L", (rows, cols), color=255)
    for img in imgs:
        pixelLoc = find_firstPixel(img)
        temp = cropImage(img)
        temp = scaleImage(temp, width, height)
        newImage.paste(temp, (pixelLoc[0], pixelLoc[1]))
    return newImage
コード例 #4
0
def findCharacter(img):
    imgTest = scaleImage(cropImage(thining(img)), 100, 100)
    testVector = getFeatureVector(imgTest)
    predictN = 0
    minValue = 999999999
    for i in range(0, 10):
        temp = averageDB(i)
        print(euclideanDistance(testVector, temp))
        if euclideanDistance(testVector, temp) < minValue:
            minValue = euclideanDistance(testVector, temp)
            predictN = i
    return predictN
コード例 #5
0
ファイル: bot.py プロジェクト: Patsonical/Discrop
async def on_message(message):
    if message.author == client.user:
        return
    for att in message.attachments:
        if att.width != None:
            imgbytes = await att.read()
            img = Image.open(BytesIO(imgbytes))
            cropped = cropImage(img)
            if cropped != None:
                outbytes = BytesIO()
                cropped.save(outbytes, format='PNG')
                outbytes.seek(0)
                out = discord.File(outbytes, filename=att.filename)
                await message.channel.send(
                    content="Let me crop that for you " +
                    message.author.mention,
                    file=out)
コード例 #6
0
ファイル: gui.py プロジェクト: Til-D/img-slicer
def cropImage():
    crop.cropImage(root.filename, root.directory)
    status.configure(text="Done.")
    status.grid(row=4, column=0)
    btn2.configure(state=DISABLED)
    btn3.configure(state=DISABLED)