コード例 #1
0
def fimage(x, y, file, type=1):
    if file[:3] == '/sd':
        utils.filecp(file, '/flash/fcache', blocksize=8192)
        lcd.image(x, y, '/flash/fcache', 0, type)
        os.remove('/flash/fcache')
    else:
        lcd.image(x, y, file, 0, type)
コード例 #2
0
ファイル: gerald.py プロジェクト: TechnoElf/gerald
def main():
    remote.synchronise()
    files = parser.parse_file_list(remote.get_content())

    while len(files) == 0:
        print("No files found, retrying...")
        remote.synchronise()
        files = parser.parse_file_list(remote.get_content())
        time.sleep(20)

    while True:
        for file in files:
            if file.type == parser.FileType.IMAGE:
                display.image(file)
            elif file.type == parser.FileType.VIDEO:
                display.video(file)
            else:
                print("Unknown file type of " + str(file.path))
コード例 #3
0
ファイル: tools.py プロジェクト: LosSherl/GAWWN.Pytorch
def showPic(imgs, locs, win=0, name="Real"):
    imgs = [(x + 0.5) / 2 * 255 for x in imgs]
    imgs = [cv2.flip(x.transpose(1, 2, 0), 0) for x in imgs]
    # imgs = [x.transpose(1, 2, 0) for x in imgs]
    for i in range(4):
        for y in range(16):
            for x in range(16):
                if locs[i][y][x] > 0.3:
                    cv2.rectangle(imgs[i], (x * 8, 127 - y * 8),
                                  (x * 8 + 8, 119 - y * 8), (0, 0, 255), 1)
                    # cv2.rectangle(imgs[i], (x * 8,  y * 8), (x * 8 + 8, y * 8 + 8), (0, 0, 255), 1)
    half = len(imgs) // 2
    row1 = np.concatenate(imgs[:half], 1)
    row2 = np.concatenate(imgs[half:], 1)
    content = np.concatenate((row1, row2), 0)
    try:
        display.image(content, win=win, title=name)
    except Exception as e:
        print(e)
コード例 #4
0
ファイル: example.py プロジェクト: iontrapnet/BEM
import random
import time

import display


def generate_image():
    X, Y = numpy.meshgrid(numpy.linspace(0, numpy.pi, 512),
                          numpy.linspace(0, 2, 512))
    z = (numpy.sin(X) + numpy.cos(Y))**2 + 0.5
    return z


i1 = generate_image()
i2 = generate_image()

display.image(i1, title='gradient')

# display.images([i2, i2, i2, i2], width=200, title='super fabio', labels=['a', 'b', 'c', 'd'])

data = []
for i in range(15):
    data.append([i, random.random(), random.random() * 2])

win = display.plot(data, labels=['position', 'a', 'b'], title='progress')

for i in range(15, 25):
    time.sleep(0.2)
    data.append([i, random.random(), random.random() * 2])
    display.plot(data, win=win)
コード例 #5
0
out_folder_name = time_info.strftime("%Y-%m-%d") + '_' \
                  + input_name[:-4] \
                  + '_2D' + time_info.strftime("_%H%M")

if not os.path.exists('./Trained_models/' + out_folder_name):
    os.mkdir('./Trained_models/' + out_folder_name)
copyfile('./train_g2d_periodic.py',
         './Trained_models/' + out_folder_name + '/code.txt')

# load images
input_texture = Image.open('./Images/' + input_name)
input_torch = Variable(prep(input_texture)).unsqueeze(0).cuda()
# display images
if disp:
    img_disp = numpy.asarray(input_texture, dtype="int32")
    display.image(img_disp, win='input', title='Input texture')

#define layers, loss functions, weights and compute optimization target
out_keys = ['r11', 'r21', 'r31', 'r41', 'r51']
loss_fns = [GramMSELoss()] * len(out_keys)
loss_fns = [loss_fn.cuda() for loss_fn in loss_fns]
# these are the weights settings recommended by Gatys
# to use with Gatys' normalization:
# w = [1e2/n**3 for n in [64,128,256,512,512]]
w = [1, 1, 1, 1, 1]

#compute optimization targets
targets = [GramMatrix()(f).detach() for f in vgg_net(input_torch, out_keys)]

# training parameters
batch_size = 10
コード例 #6
0
ファイル: example.py プロジェクト: dimatura/display
#!/usr/bin/env python

import numpy
import random
import time

import display

def generate_image():
    X, Y = numpy.meshgrid(numpy.linspace(0, numpy.pi, 512), numpy.linspace(0, 2, 512))
    z = (numpy.sin(X) + numpy.cos(Y)) ** 2 + 0.5
    return z

i1 = generate_image()
i2 = generate_image()

display.image(i1, title='gradient')

# display.images([i2, i2, i2, i2], width=200, title='super fabio', labels=['a', 'b', 'c', 'd'])

data = []
for i in range(15):
    data.append([i, random.random(), random.random() * 2])

win = display.plot(data, labels=[ 'position', 'a', 'b' ], title='progress')

for i in range(15, 25):
    time.sleep(0.2)
    data.append([i, random.random(), random.random() * 2])
    display.plot(data, win=win)
コード例 #7
0
import cv2

import display
display.set_port(9000)


def generate_image():
    X, Y = np.meshgrid(np.linspace(0, np.pi, 512), np.linspace(0, 2, 512))
    z = (np.sin(X) + np.cos(Y))**2 + 0.5
    return z


i1 = generate_image()
i2 = generate_image()

display.image(i1, title='gradient')

# display.images([i2, i2, i2, i2], width=200, title='super fabio', labels=['a', 'b', 'c', 'd'])

data = []
for i in range(15):
    data.append([i, random.random(), random.random() * 2])

win = display.plot(data, labels=['position', 'a', 'b'], title='progress')

for i in range(15, 25):
    time.sleep(0.2)
    data.append([i, random.random(), random.random() * 2])
    display.plot(data, win=win)

im = cv2.imread('example.png')
コード例 #8
0
                  + inputs_names[0][:-4] \
                  + '_3D' + time_info.strftime("_%H%M")
if not os.path.exists('./Trained/' + out_folder_name):
    os.mkdir('./Trained/' + out_folder_name)

# load images
input_textures = [Image.open('./Textures/' + name) for name in inputs_names]
input_textures_torch = [
    Variable(prep(img)).unsqueeze(0).cuda() for img in input_textures
]
# display images
if disp:
    for i, img in enumerate(input_textures):
        img_disp = numpy.asarray(img, dtype="int32")
        display.image(img_disp,
                      win=['input' + str(i)],
                      title=['Input texture d' + str(i)])

#define layers, loss functions, weights and compute optimization target
loss_layers = ['r11', 'r21', 'r31', 'r41', 'r51']
loss_fns = [GramMSELoss()] * len(loss_layers)
loss_fns = [loss_fn.cuda() for loss_fn in loss_fns]
w = [1, 1, 1, 1, 1]

#compute optimization targets
targets = []
for img in input_textures_torch:
    targets.append([GramMatrix()(f).detach() for f in vgg(img, loss_layers)])

# training parameters
slice_size = 128  # training slice resolution (best if same as examples)
コード例 #9
0
    print(f, " - ", len(eps), " len: ", len(eyes))
    result.append(np.asarray(eps))

    for ei in range(len(eps)):
        x, y, w, h = eps[ei]
        if w > 0 and h > 0:
            print("eye @ ", eps[ei])
            eye_img = image[y:y + h, x:x + w]
            cv2.imwrite(f"{args.output}/eye_{ei}_{f}", eye_img)

    # cv2.imwrite(args.output + "/final.png", image)
    # print(type(image), image.shape)
    if args.display:
        destRGB = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        destRGB = cv2.flip(destRGB, 0)
        display.image(destRGB, win='eye', title='eyes', width=800, height=450)

# cv2.imshow('Lets wear Glasses', image)
# cv2.waitKey()
# cv2.destroyAllWindows()

# net = BlurConv(3, 7, 1.5)
# print(net)

print(len(result))

result = np.asarray(result)

print(result.shape)

numlist = np.asarray(numlist)