Example #1
0
def main(yf):
    parser = ParseYaml(yf)

    to_preprocessing = parser.get_item("to_preprocessing")
    to_train = parser.get_item("to_train")
    to_demo = parser.get_item("to_demo")
    to_plots = parser.get_item("to_plots")

    preprocessing_config = parser.get_item("preprocessing")
    if to_preprocessing:
        preprocessing.preprocessing(preprocessing_config)

    train_config = parser.get_item("train")
    if to_train:
        train.train(train_config)

    demo_config = parser.get_item("demo")
    if to_demo:
        demo.demo(demo_config)

    plot_config = parser.get_item("plots")
    if to_plots:
        plots.line_plot(plot_config.get("line_plot"))
        # print("---1---")
        plots.day_scatter_plot(plot_config.get("day_scatter_plot"))
        plots.multi_day_scatter_plot(plot_config.get("multi_day_scatter_plot"))
        # print("---2---")
        plots.hist_plot(plot_config.get("hist_plot"))
        # print("---3---")
        plots.day_map_plot(plot_config.get("day_map_plot"))
        plots.mutli_day_map_plot(plot_config.get("multi_day_map_plot"))
Example #2
0
def analyze(opts):
    # use sys.stdin insted if no filename is specified
    if len(opts.filenames) == 0:
        opts.filenames.append(sys.stdin)

    if opts.demo:
        data = [demo(), demo(), demo()]
    else:
        # load data file
        data = [load(f, opts) for f in opts.filenames]
    # transform to 1-dimensional array
    data = concatenate(data, axis=0)

    # modulate the data with base
    data = modulate_base(data, opts.base)

    # convert Decimal to float

    # remove data with threshold
    if opts.min_threshold:
        data = data[data>opts.min_threshold]
    if opts.max_threshold:
        data = data[data<opts.max_threshold]

    # fitting
    kwargs = dict(
        n_components=opts.classifiers,
        covariance_type=opts.covariance_type,
        min_covar=opts.min_covar)
    model, criterions = fit(data, **kwargs)

    # call function
    return opts.func(data, model, criterions, opts)
Example #3
0
def main():
    assert FLAG.MODE in ('train', 'valid', 'demo')

    if FLAGS.MODE == 'demo':
        demo(FLAGS.checkpoint_dir, FLAGS.show_box)
    elif FLAGS.MODE == 'train':
        train_model(FLAGS.train_data)
def main():
  assert FLAGS.MODE in ('train', 'valid', 'demo')
  
  if FLAGS.MODE == 'demo':
    demo(FLAGS.checkpoint_dir, FLAGS.show_box)
  elif FLAGS.MODE == 'train':
    train_model(FLAGS.train_data)
  elif FLAGS.MODE == 'valid':
    valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
Example #5
0
def main():
    assert FLAGS.MODE in ('train', 'valid', 'demo')
    # FLAGS.MODE 中含有‘train’,‘valid’,‘demo’ 三个字符串
    if FLAGS.MODE == 'demo':
        demo(FLAGS.checkpoint_dir, FLAGS.show_box)
        # 运行 demo.demo()
    elif FLAGS.MODE == 'train':
        train_model(FLAGS.train_data)
    elif FLAGS.MODE == 'valid':
        valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
Example #6
0
def main():
    assert FLAGS.MODE in ('train', 'valid', 'demo')
    tf.compat.v1.disable_eager_execution()

    if FLAGS.MODE == 'demo':
        demo(FLAGS.checkpoint_dir, FLAGS.show_box)
    elif FLAGS.MODE == 'train':
        train_model(FLAGS.train_data)
    elif FLAGS.MODE == 'valid':
        valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
def deal_with_filename(subdir):
    targetsub = '/media/ustb/Dataset2/biovid/PartA/reprocess_slstm/B_data_argu_front'

    # start_frame = os.listdir(subdir)
    # for each_frame in start_frame:
    #     classes = os.listdir(os.path.join(subdir,each_frame))
    #     for each_class in classes:
    #         samples = os.listdir(os.path.join(subdir,each_frame,each_class))
    samples = os.listdir(subdir)
    for each_sample in samples:
        imgs = os.listdir(os.path.join(subdir, each_sample))
        for filename1 in imgs:
            print(os.path.join(subdir, each_sample))
            S = os.path.join(subdir, each_sample).split('/')
            the_class = S[9]
            sample_name = S[10]
            frame = cv2.imread(os.path.join(subdir, each_sample, filename1))
            target_filename = os.path.join(targetsub, the_class, sample_name,
                                           filename1)
            print(target_filename)
            base_path = '/media/ustb/Personalfiles/Wandameng/1.jpg'
            count = 1
            # face alignment
            im1, im2, M, landmark1, landmark2 = face_landmark_detection.face_align(
                base_path, frame, 0)
            warped_im2 = im2
            if M == [1, 1]:
                warped_img2 = im2
                print('error')
                #### dont save the pictures which were failed to do the face alignment
                continue
            else:
                landmark2 = np.array(landmark2)
                landmark1 = np.array(landmark1)
                b = np.array([[
                    landmark2[0], landmark2[1], landmark2[2], landmark2[3],
                    landmark2[4], landmark2[5], landmark2[6], landmark2[7],
                    landmark2[8], landmark2[9], landmark2[10], landmark2[11],
                    landmark2[12], landmark2[13], landmark2[14], landmark2[15],
                    landmark2[16], landmark2[26], landmark2[25], landmark2[24],
                    landmark2[19], landmark2[18], landmark2[17]
                ]],
                             dtype=np.int32)
                im = np.zeros(im2.shape[:2], dtype="uint8")
                cv2.polylines(im, b, 1, 255)
                cv2.fillPoly(im, b, 255)
                #face frontalization and crop
                mask = im
                masked = cv2.bitwise_and(im2, im2, mask=mask)

                warped_im2 = face_landmark_detection.warp_im(
                    masked, M, im1.shape)

            front_img = demo.demo(warped_im2)
            #cv2.imshow('alignment img', front_i  mg)
            #cv2.waitKey(4)
            cv2.imwrite(target_filename, front_img)
            print(count)
            count += 1
Example #8
0
def main():
    parser = get_parser()
    config = parser.parse_args()
    if config.train:
        auto(config, 'train')
        val_config = parser.parse_args()
        auto(val_config, 'val')
        val_config.train = False
        run.train(config, val_config=val_config)
    else:
        if config.serve:
            auto(config, 'serve')
            config.fresh = True
            demo.demo(config)
        else:
            auto(config, 'test')
            run.test(config)
Example #9
0
def deal_with_filenanme(subdir):
    for filename1 in os.listdir(subdir):
        filename = subdir + '/' + filename1
        s = filename1.split('-')
        if (s[1] == 'BL1'):
            target_sub = target_root + '0/'
        elif (s[1] == 'PA1'):
            target_sub = target_root + '1/'
        elif (s[1] == 'PA2'):
            target_sub = target_root + '2/'
        elif (s[1] == 'PA3'):
            target_sub = target_root + '3/'
        elif (s[1] == 'PA4'):
            target_sub = target_root + '4/'
        target_sub = target_sub + s[0] + '-' + s[1] + '-' + s[2][:3]
        if not os.path.exists(target_sub):
            os.makedirs(target_sub)
        target_files = target_sub + '/*'
        images_count = len(glob.glob(target_files))
        print("images_count",images_count)
        if images_count == 138:
            print("full_full")
        else:
            cap = cv2.VideoCapture(filename)
            base_path = '/home/yjw/2.png'
            count = 1
            while (cap.isOpened() == True):
                target_filename = target_sub + '/' + str(count) + '.png'
                ret, frame = cap.read()
                if ret == True:
                    im1, im2, M, landmark1, landmark2 = face_landmark_detection.face_align(base_path, frame, 0)
                    if M == [1, 1]:
                        warped_img2 = im2
                    else:
                        landmark2 = np.array(landmark2)
                        landmark1 = np.array(landmark1)
                        b = np.array(
                                [[landmark2[0], landmark2[1], landmark2[2], landmark2[3], landmark2[4], landmark2[5],
                                  landmark2[6], landmark2[7], landmark2[8], landmark2[9], landmark2[10], landmark2[11],
                                  landmark2[12], landmark2[13], landmark2[14], landmark2[15], landmark2[16],
                                  landmark2[26],
                                  landmark2[25], landmark2[24], landmark2[19], landmark2[18], landmark2[17]]],
                                dtype=np.int32)
                        im = np.zeros(im2.shape[:2], dtype="uint8")
                        cv2.polylines(im, b, 1, 255)
                        cv2.fillPoly(im, b, 255)
                        mask = im
                        masked = cv2.bitwise_and(im2, im2, mask=mask)

                        warped_im2 = face_landmark_detection.warp_im(masked, M, im1.shape)
                    front_img = demo.demo(warped_im2)
                    print(target_filename)
                    cv2.imwrite(target_filename, front_img)

                else:
                    break
                print(count)
                count += 1
Example #10
0
def run_detector(*argv):
    """argv: 'darknet' 'detector' 'test|demo' data cfg weight jpg|cam mp4"""
    if argv[2] == 'test':
        argv = [x for x in argv if x != 'test']
        argv.append('.5')  #thresh
        argv.append('.5')  #hier_thresh
        argv.append('.45')  #nms
        test_detector(*argv)
    elif argv[2] == 'demo':
        argv = [x for x in argv if x != 'demo']
        argv.insert(5, '.5')  #thresh
        if len(argv) == 7:
            argv.append(None)  #mp4
        elif len(argv) > 7:
            if not os.path.exists(os.path.join(os.getcwd(), argv[7])):
                argv[7] = None
        demo(*argv)
    else:
        print('Not implement')
Example #11
0
def main():
    assert FLAGS.MODE in ('train', 'valid', 'demo')

    if FLAGS.MODE == 'demo':
        x = demo(FLAGS.checkpoint_dir, FLAGS.show_box, SAMPLE_IMAGE_PATH)
        print("test: = " + str(x))
    elif FLAGS.MODE == 'train':
        train_model(FLAGS.train_data)
    elif FLAGS.MODE == 'valid':
        valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)
    def runCamera(self):
        if self.camera.isOpened():
            rval, frame = self.camera.read()
            self.img = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
            self.label.setPixmap(QPixmap(self.convertMatToQImage(self.img)))

            detect = demo.demo(frame)
            detect = cv2.cvtColor(detect, cv2.COLOR_BGR2RGB)
            self.label_2.setPixmap(QPixmap(self.convertMatToQImage(detect)))
        else:
            rval = False
Example #13
0
def interact():
    print(dir(request))
    if request.method == 'POST':
        data = request.get_data().decode("utf-8")
        data = json.loads(data)
        sentence = data['sentence']
        answer = data['answer']
    else:
        sentence = 'There are 5000000 people in the united states .'
        answer = '5000000'
    question = demo(sentence, answer, logger, params, vocab, model, generator)
    ret = json.dumps({'return': question})
    return ret
    def post(self):

        x = ""
        self.bytes_to_img(request.form['img'])
        if FLAGS.MODE == 'demo':
            img = Image.open('temp_file.jpg')
            open_cv_image = numpy.array(img)
            open_cv_image = open_cv_image[:, :, ::-1].copy()
            x = demo(FLAGS.checkpoint_dir, FLAGS.show_box, open_cv_image)
            print("test: = " + str(x))
        elif FLAGS.MODE == 'train':
            train_model(FLAGS.train_data)
        elif FLAGS.MODE == 'valid':
            valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)

        return json.loads(x)
Example #15
0
    def post(self):
        x = ""
        if not request.files:
            return 'File Not Found'
        img = Image.open(request.files['file'])
        if FLAGS.MODE == 'demo':
            img = Image.open(request.files['file'])
            open_cv_image = numpy.array(img)
            open_cv_image = open_cv_image[:, :, ::-1].copy()
            x = demo(FLAGS.checkpoint_dir, FLAGS.show_box, open_cv_image)
            print("test: = " + str(x))
        elif FLAGS.MODE == 'train':
            train_model(FLAGS.train_data)
        elif FLAGS.MODE == 'valid':
            valid_model(FLAGS.checkpoint_dir, FLAGS.valid_data)

        return json.loads(x)
Example #16
0
# # print B
# # print C

# ------Check nadjacency function

# dname = 'Erdos02-cc'
# A, mylambda = load_graph(dname)
# N = nadjacency(A)

# ------Check Demo function

filenames = os.listdir('data')
for filename in filenames:
	if (filename[0] != '.' and filename.endswith(".smat.gz")):
		print (filename[:-8])
		demo(filename[:-8])

# # dname = 'marvel-chars-cc'
# # demo(dname)

## ------Check eigen function
# filename = "musm-cc"
# fullfilename = 'data/' + filename + '.smat.gz'
# A, n = readSMAT(fullfilename)
# print n
# print A
# B = calcEigen(A, n)
# normalizedB = B / float(max(B)) + 1
# print normalizedB

# # print file_content
Example #17
0
                        b = np.array([[
                            landmark2[0], landmark2[1], landmark2[2],
                            landmark2[3], landmark2[4], landmark2[5],
                            landmark2[6], landmark2[7], landmark2[8],
                            landmark2[9], landmark2[10], landmark2[11],
                            landmark2[12], landmark2[13], landmark2[14],
                            landmark2[15], landmark2[16], landmark2[26],
                            landmark2[25], landmark2[24], landmark2[19],
                            landmark2[18], landmark2[17]
                        ]],
                                     dtype=np.int32)
                        im = np.zeros(im2.shape[:2], dtype="uint8")
                        cv2.polylines(im, b, 1, 255)
                        cv2.fillPoly(im, b, 255)
                        mask = im
                        masked = cv2.bitwise_and(im2, im2, mask=mask)

                        warped_im2 = face_landmark_detection.warp_im(
                            masked, M, im1.shape)
                        cv2.imshow('alignment img', warped_im2)
                        cv2.waitKey(0)
                    front_img = demo.demo(warped_im2)
                    cv2.imshow('alignment img', front_img)
                    cv2.waitKey(0)
                    #cv2.imwrite(target_filename,front_img)

                else:
                    break
                print(count)
                count += 1
Example #18
0
                break
            except:
                pass

    # -- Facet Event Handlers ---------------------------------------------------

    def _snap_set(self):
        """ Handles the 'snap' event being fired.
        """
        self.image = self.ui.control.image
        self.image.save(file_with_ext(self.demo_file.path, "png"))

    def _next_set(self):
        """ Handles the 'next' event being fired.
        """
        inn(self.demo_file.demo, "dispose")()
        self.ui.dispose()
        self.demo_file = self.ui = None
        self._process_file()


# -- Run the program (if invoked from the command line) -------------------------

if __name__ == "__main__":
    import facets.extra.demo.ui

    ImageLibrary().add_volume(join(dirname(facets.extra.demo.ui.__file__), "images"))
    DemoScreenShots(demo=demo(run=False)).edit_facets()

# -- EOF ------------------------------------------------------------------------
Example #19
0
                                             args.poly, refine_net)

        # save score text
        filename, file_ext = os.path.splitext(os.path.basename(image_path))
        Indx = file_utils.saveResult(Indx,
                                     image_path,
                                     image[:, :, ::-1],
                                     polys,
                                     dirname=result_folder)

    for k, image_path in enumerate(image_list2):
        print("Test image {:d}/{:d}: {:s}".format(k + 1, len(image_list2),
                                                  image_path),
              end='\r')
        image = imgproc.loadImage(image_path)

        bboxes, polys, score_text = test_net(net, image, args.text_threshold,
                                             args.link_threshold,
                                             args.low_text, args.cuda,
                                             args.poly, refine_net)

        # save score text
        filename, file_ext = os.path.splitext(os.path.basename(image_path))
        Indx = file_utils.saveResult(Indx,
                                     image_path,
                                     image[:, :, ::-1],
                                     polys,
                                     dirname=result_folder2)

    demo(args)
    print("elapsed time : {}s".format(time.time() - t))
Example #20
0
                    batch_size=192,
                    character='0123456789abcdefghijklmnopqrstuvwxyz',
                    hidden_size=256,
                    image_folder=args['output'],
                    imgH=32,
                    imgW=100,
                    input_channel=1,
                    num_fiducial=20,
                    num_gpu=0,
                    output_channel=512,
                    rgb=False,
                    saved_model='weights/TPS-ResNet-BiLSTM-Attn.pth',
                    sensitive=False,
                    workers=4)
    opt.num_gpu = torch.cuda.device_count()
    extract_text = demo.demo(opt)
    # print(extract_text)

    for filename in os.listdir(args['output']):
        file_path = os.path.join(args['output'], filename)
        try:
            if os.path.isfile(file_path) or os.path.islink(file_path):
                os.unlink(file_path)
            elif os.path.isdir(file_path):
                shutil.rmtree(file_path)
        except Exception as e:
            print('Failed to delete %s. Reason: %s' % (file_path, e))

    with open(args['output'] + '/extracted.txt', 'w') as f:
        for item in extract_text:
            f.write("%s\n" % item)
Example #21
0
from demo import demo

demo(random_seed=None)
Example #22
0
from utils.config import Config
from utils.misc import init_env

cfg = Config().parse()
init_env(cfg)

if cfg.mode == 'train':
    from train import train
    train(cfg)
elif cfg.mode == 'eval':
    from eval import eval
    eval(cfg)
elif cfg.mode == 'demo':
    from demo import demo
    demo(cfg)
else:
    raise ValueError('Mode {} is invalid.'.format(cfg.mode))
Example #23
0
def main():
    demo('D:/face/models', True)
import sys
from demo import demo

print(sys.argv[0])

demo("data/notredame/notre_dame_1.jpg", "data/notredame/notre_dame_2.jpg", 0.5,
     0.5, 0.0001)
demo("data/rushmore/rush1.jpg", "data/rushmore/rush0.jpg", 0.12, 0.04, 0.00001)
demo("data/gaudi/gaudi_1.jpg", "data/gaudi/gaudi_2.jpg", 0.7, 0.3, 0.001)

#demo("data/plane.bmp","data/plane.bmp")
#demo(sys.argv[1],sys.argv[2],.5,.5,0.0001)
Example #25
0
from task import interact
import gym
import numpy as np
import argparse
import pickle

parser = argparse.ArgumentParser()
parser.add_argument('--dt',
                    type=str,
                    default='d',
                    help='d: demo(default), t:train')
in_args = parser.parse_args()
dt = in_args.dt.lower()
print("train/demo: ", dt)

env = RescueEnv()

if dt == 't':
    agent = Agent()
    while True:
        try:
            avg_rewards, highest_avg_reward, lowest_avg_reward = interact(
                env, agent)
            break
        except TypeError:
            print('\n', "           Simulation end!")
            break

if dt == 'd':
    demo.demo(env)
Example #26
0
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# author:zhangjiao
# import day09.demo2 as demo2

# print(demo2.qiuhe(10))
# print(demo2.qiujiecheng(5))
# print(demo2.jiechenghe(5))

#
# from day09.demo2 import qiuhe
#
# print(qiuhe(10))
#
#
# from  day09.demo2 import *
#
# print(qiuhe(100))
# print(qiujiecheng(10))
# print(jiechenghe(5))

import math

print(math.pow(2, 3))

from demo import demo

demo()
Example #27
0
Bugs:

 -  No attempt is made to check for errors reported by gnuplot.  On
    unix any gnuplot error messages simply appear on stderr.  (I don't
    know what happens under Windows.)

 -  All of these classes perform their resource deallocation when
    '__del__' is called.  Normally this works fine, but there are
    well-known cases when Python's automatic resource deallocation
    fails, which can leave temporary files around.

"""

__version__ = '1.8'

# Other modules that should be loaded for 'from Gnuplot import *':
__all__ = ['utils', 'funcutils', ]

from gp import GnuplotOpts, GnuplotProcess, test_persist
from Errors import Error, OptionError, DataError
from PlotItems import PlotItem, Func, File, Data, GridData
from _Gnuplot import Gnuplot


if __name__ == '__main__':
    import demo
    demo.demo()


Example #28
0
        # earlystop,
        tensorBoard,
    ]
    model = create_model()
    model.compile(loss='categorical_crossentropy',
                  optimizer='adam',
                  metrics=['accuracy'])
    model.summary()

    train_dataset, test_dataset = create_train_test(directory,
                                                    maximum=maximum,
                                                    batch_size=batch_size,
                                                    train_p=train_percent)

    history = model.fit(
        train_dataset,
        validation_data=test_dataset,
        validation_steps=(total_files - int(total_files * train_percent)) //
        batch_size,
        steps_per_epoch=int(total_files * train_percent) // batch_size,
        batch_size=batch_size,
        epochs=epochs,
        callbacks=callbacks_list)
    plot_history(history)

    eval = test_dataset.__next__()
    x_eval = eval[0]
    y_true = np.array(eval[1])

    demo(model, x_eval, y_true, save=True)
Example #29
0
def main(path_name, n):
    #x, y = plots(n)
    demo(path_name, n)
Example #30
0
            for k in range(8):
                ii = i + ci[k]
                jj = j + cj[k]
                if ii >= 0 and ii < n_row and jj >= 0 and jj < n_col:
                    v = id[(xs[ii], ys[jj])]
                    edges[(u, v)] = l2distance(vertices[u][2], vertices[u][3], vertices[v][2], vertices[v][3]) * 10 # * randint(2, 100)

    n_vertice = len(vertices)
    n_edge = len(edges)

    with open(file_name, 'w') as file:
        file.write('{}\n'.format(n_vertice))
        for i in range(n_vertice):
            file.write('{} {} {} {}\n'.format(*vertices[i]))
        file.write('{}\n'.format(n_edge))
        for (u, v) in edges.keys():
            file.write('{} {} {}\n'.format(u, v, edges[(u, v)]))
        file.write('{} {}'.format(randint(0, n_vertice - 1), randint(0, n_vertice - 1)))


n_test = 10
for test_id in range(n_test):
    print '\n---\nTEST {}'.format(test_id)
    n_vertice = randint(10000, 200000)
    n_edge = n_vertice * randint(1, (n_vertice - 1) / 2)
    print '#vertices = {}, #edges = {}'.format(n_vertice, n_edge)
    generate_grid_input(n_vertice, n_edge, 'temp.txt')

    for algorithm in algorithms:
        demo.demo(algorithm, 'temp.txt', None)
Example #31
0
            # In this case, we only care about 'SURE' translations.
        
        sentence = AlignedSent (mem['e'][index], 
                                mem['f'][index], 
                                mem['wa'][index], 'S')

        translation[index] = sentence

    return translation


if __name__ == "__main__":
    '''
        main function - demonstrate the functionality of the AlignedSent class
    '''
    #pylint: disable-msg=C0103

    args = sys.argv
    if len(args) != 2:
        print 'path name should be specified after the program name'
        exit(0)
    for arg in args:
        if 'load.py' in arg:
            continue
        else:
            filname = arg

    translation = load(filname)
    demo(translation)

Example #32
0
# # print B
# # print C

# ------Check nadjacency function

# dname = 'Erdos02-cc'
# A, mylambda = load_graph(dname)
# N = nadjacency(A)

# ------Check Demo function

filenames = os.listdir('data')
for filename in filenames:
    if (filename[0] != '.' and filename.endswith(".smat.gz")):
        print(filename[:-8])
        demo(filename[:-8])

# # dname = 'marvel-chars-cc'
# # demo(dname)

## ------Check eigen function
# filename = "musm-cc"
# fullfilename = 'data/' + filename + '.smat.gz'
# A, n = readSMAT(fullfilename)
# print n
# print A
# B = calcEigen(A, n)
# normalizedB = B / float(max(B)) + 1
# print normalizedB

# # print file_content
Example #33
0
import random
import lib2d
from demo import demo


def setup(scene):
    r = lambda: random.random()

    for i in range(2400):
        s = lib2d.Sprite("rounded_square.png")
        s.blend(lib2d.flags.BLEND_PREMULT)
        s.rgba(.5, .2, 1, .2)
        s.rgba(0, .8, 0, .6, 3 * r() + 2, lib2d.flags.ANIM_REVERSE)

        s.xy(r() * 640, r() * 480)
        s.xy(r() * 640, r() * 480, 2, lib2d.flags.ANIM_EXTRAPOLATE)
        s.wrap_xy(0, 640, 0, 480)

        s.scale(.1)
        s.scale(1, r() + .75, lib2d.flags.ANIM_REVERSE)

        s.rot(360, 2, lib2d.flags.ANIM_REPEAT)

    print("Drawing 2,400 sprites...")


demo(b"lib2d lotsofsprites demo", setup, framelock=False)
 def on_pushButton_2_clicked(self):
     """
     Slot documentation goes here.
     """
     detect = demo.demo(self.img)
     self.label.setPixmap(QPixmap(self.convertMatToQImage(detect)))
Example #35
0
def run_demo(args):
    demo(args.modelPath, args.showbox)
Example #36
0
 -  No attempt is made to check for errors reported by gnuplot.  On
    unix any gnuplot error messages simply appear on stderr.  (I don't
    know what happens under Windows.)

 -  All of these classes perform their resource deallocation when
    '__del__' is called.  Normally this works fine, but there are
    well-known cases when Python's automatic resource deallocation
    fails, which can leave temporary files around.

"""
import os, sys

sys.path.append(os.path.dirname(__file__))

__version__ = "1.8"

# Other modules that should be loaded for 'from Gnuplot import *':
__all__ = ["utils", "funcutils"]

from gp import GnuplotOpts, GnuplotProcess, test_persist
from Errors import Error, OptionError, DataError
from PlotItems import PlotItem, Func, File, Data, GridData
from _Gnuplot import Gnuplot


if __name__ == "__main__":
    import demo

    demo.demo()
import lib2d
from demo import demo


class Demo:
    SEQUENCES = ("climb", 2), ("swim", 2), ("walk", 2), ("duck", 1)

    def setup(self, scene):
        s = scene.make_sprite("anim/alienGreen.png")
        s.xy(320, 240)
        self.s = s

        for n, c in self.SEQUENCES:
            seq = s.new_sequence(n)
            for i in range(1, c + 1):
                seq.add_frame("anim/alienGreen_" + n + str(i) + ".png", 0.27)

        s.sequences['climb'].play(flags=lib2d.flags.ANIM_REPEAT)
        self.current = 0

    def on_click(self, x, y):
        self.current = (self.current + 1) % len(self.SEQUENCES)
        n = self.SEQUENCES[self.current][0]
        self.s.sequences[n].play(flags=lib2d.flags.ANIM_REPEAT)


d = Demo()

demo(b"Sprite sequence demo", d.setup, d.on_click)