Example #1
0

canny = Overlay("canny.xclbin")

image_path = "input_image.jpg"
original_image = Image.open(image_path)

canny_edge = canny.canny_1
canny_edge.signature

low_threshold = 0
high_threshold = 255
height = 1920
width = 1080

in_buffer = allocate((height, width), np.uint8)
out_buffer = allocate((height, width), np.uint8)

start_time = time.time()

in_buffer.sync_to_device()
canny_edge.call(in_buffer, out_buffer, height, width, low_threshold, high_threshold)
out_buffer.sync_from_device()

stop_time = time.time()
print("--- %s seconds ---" % (stop_time - start_time))

get_ipython().run_line_magic('xdel', 'in_buffer')
get_ipython().run_line_magic('xdel', 'out_buffer')
canny.free()
Example #2
0
out_buffer.sync_from_device()
stop_time = time.time()
print("--- %s seconds ---" % (stop_time - start_time))

# In[167]:

out_buffer[50][50]

# In[126]:

# deallocate the buffers and free the FPGA context using Overlay.free
get_ipython().run_line_magic('xdel', 'in_buffer1')
get_ipython().run_line_magic('xdel', 'in_buffer2')
get_ipython().run_line_magic('xdel', 'out_buffer')
overlay.free()

# In[148]:

A = np.zeros((size, size), np.uint32)
B = np.zeros((size, size), np.uint32)
C = np.zeros((size, size), np.uint32)

# In[149]:

for i in range(size):
    for j in range(size):
        A[i][j] = fixed_num
        B[i][j] = fixed_num
        C[i][j] = 0