Пример #1
0
def main():
    img = extension.load_data()
    extension.visualize(img, 'gray')

    detector = ced.cannyEdgeDetector(img, sigma=1.4, kernel_size=5, lowthreshold=0.09, highthreshold=0.17, weak_pixel=100)
    final_img = detector.detect()

    extension.visualize(final_img, 'gray')
Пример #2
0
def CannyEdgeDetection():
    if request.method == 'POST':
        data = request.get_json()
        # print(data)
        x = data["base64Image"].split(",")
        base64_img = x[1]
        size, imgs = utils.load_singleImage(base64_img)
        detector = ced.cannyEdgeDetector(imgs, sigma=1.4, kernel_size=5, lowthreshold=0.09, highthreshold=0.17, weak_pixel=100)
        imgs_final, base64_img_string = detector.detect(convertBase64=True)
        return_dict = {
            "base64Image": base64_img_string,
            "size": size
        }
        print("OK")
        # print(locations)
    return(json.dumps(return_dict))
Пример #3
0
def canny(input):
    edge_gray = rgb2gray(input)
    detector = ced.cannyEdgeDetector(edge_gray, sigma=1.4, kernel_size=5, lowthreshold=0.09, highthreshold=0.17, weak_pixel=100)
    return detector.detect()
Пример #4
0
# Script to generate doge-like ascii levels from images

# https://github.com/FienSoP/canny_edge_detector
from canny_edge_detector import cannyEdgeDetector
from utils.utils import load_data
from utils.utils import visualize

# https://github.com/RameshAditya/asciify
from asciify import do
from PIL import Image 
import numpy as np

img = load_data("imgs")

ced = cannyEdgeDetector(img, sigma=1, kernel_size=5, weak_pixel=75, strong_pixel=255, lowthreshold=0.05, highthreshold=0.15)

imgs = ced.detect()

# visualize(imgs)

j = 1
for i in imgs: 
    f = open('level' + str(j) + '.txt','w')
    f.write( do(Image.fromarray(i)) )
    f.close()
    j = j + 1


# convert from array to image
# img_obj = Image.fromarray(imgs[3])
# imgtxt = do(img_obj)
Пример #5
0
import cv2
import canny_edge_detector as ced
import numpy as np

cap = cv2.VideoCapture(0)
while True:
    ret, img = cap.read()

    # gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
    # blur = cv2.GaussianBlur(gray, (5, 5), 0)
    # canny = cv2.Canny(blur, 10, 70)
    # ret, mask = cv2.threshold(canny, 70, 255, cv2.THRESH_BINARY)
    detector = ced.cannyEdgeDetector([img],
                                     sigma=1.4,
                                     kernel_size=5,
                                     lowthreshold=0.09,
                                     highthreshold=0.17,
                                     weak_pixel=100,
                                     useCVConvolution=True)
    mask = detector.detect()
    print(mask)
    mask = np.array(mask, dtype=np.uint8)
    cv2.imshow('Video feed', mask)

    if cv2.waitKey(1) == 13:
        break
cap.release()
cv2.destroyAllWindows()
Пример #6
0
import traceback

import cv2, sys, os
import numpy as np
from matplotlib import pyplot as plt

# Read image
img = cv2.imread('circles.png', cv2.IMREAD_GRAYSCALE)

import canny_edge_detector as ced
detector = ced.cannyEdgeDetector(img,
                                 sigma=1.4,
                                 kernel_size=5,
                                 lowthreshold=0.09,
                                 highthreshold=0.17,
                                 weak_pixel=100)

img = detector.detect()

# cv2.imshow("canny",img)
# cv2.waitKey(0)

param1 = 80
param2 = 44
minRadius = 30
maxRadius = 50
radius = np.arange(minRadius, maxRadius, 1)
# fi_range = [0,45,90,135,180,225,270,315]
fi_range = range(0, 360, 10)

H = np.zeros(img.shape + (maxRadius, ))  #3D matrix