コード例 #1
0
def save_used_cuts(collage, timestamps):
    db = util.get_db()
    cur = db.cursor()
    for movie_id, time_slice, _ in timestamps:
        cur.execute('INSERT INTO used_cuts (collage, movie_id, start, end) VALUES (?, ?, ?, ?)',
                    (collage, movie_id, time_slice[0], time_slice[1]))
    db.commit()
コード例 #2
0
ファイル: signal1.py プロジェクト: QRAAT/sim
def test_bearing(): 
  
  cal_id = 3
  dep_id = 105
  t_start = 1407452400 
  t_end = 1407455985 #- (50 * 60)

  db_con = util.get_db('reader')
  sv = position.steering_vectors(db_con, cal_id)
  signal = Signal(db_con, dep_id, t_start, t_end)

  bearings = signal.get_bearings(sv, 3)
  p = GeneralizedVonMises.mle(bearings)

  fig, ax = pp.subplots(1, 1)

  # Plot bearing distribution.
  N = 100
  n, bins, patches = ax.hist(bearings,
                             bins = [ (i * 2 * np.pi) / N for i in range(N) ],
                             normed = 1.0,
                             facecolor='blue', alpha=0.25)

  # Plot fitted vonMises distribution.
  x = np.arange(0, 2*np.pi, np.pi / 180)
  print np.sum(p(x) * (np.pi / 180))
  pp.xlim([0,2*np.pi])
  ax.plot(x, p(x), 'k-', lw=2, 
    label='$\mu_1=%.2f$, $\mu_2=%.2f$, $\kappa_1=%.2f$, $\kappa_2=%.2f$' % (
             p.mu1, p.mu2, p.kappa1, p.kappa2))

  pp.xlim([0,2*np.pi])
  
  ax.legend(loc='best', frameon=False)
  pp.show()
コード例 #3
0
ファイル: test.py プロジェクト: kgmour/todo
def user(username=None):

    # User creation
    if request.method == 'POST':

        # We are using a serializer to validate data
        data_validator = UserSchema().load(request.json)

        # If we have errors
        if data_validator.errors:
            # We send back the errors with a 400
            return jsonify(data_validator.errors), 400
        else:

            # Are getting the cursor to the database
            cursor = get_db()
            try:

                to_commit = """
                INSERT INTO users (username, age, occupation) 
                VALUES ('{username}', '{age}', '{occupation}')
                """.format(**data_validator.data).strip()

                cursor.execute(to_commit)
                cursor.commit()
            except sqlite3.DatabaseError as e:
                return jsonify("Error in creation"), 400
            return jsonify("We created your goddam user. Be happy now."), 201
    # Getting the user
    elif request.method == 'GET':

        # Guess who has to implement this!!!!!!!?????
        return jsonify("Not implemented yet"), 400
コード例 #4
0
def make_screens(movie_id, filename, duration, orientation, screens_tmp):
    # Originally tried using the FPS filter, but I'm not really sure
    # where the first thumbnail starts and so that makes it hard to
    # match thumbnails with timestamps.  This way is slower, but I
    # have more control.
    screens_tmp.mkdir(exist_ok=False)
    rng = range(C.SCREENSHOT_START, int(duration), C.SCREENSHOT_FREQUENCY)
    video_filters = 'stereo3d={}l:ml'.format(orientation)
    db = util.get_db()
    cursor = db.cursor()
    for i, ts in enumerate(rng):
        thumbnail = screens_tmp.joinpath('thumb{:04d}.jpg'.format(i))
        cmd = 'ffmpeg -ss {} -i "{}" -vf "{}" -vframes 1 "{}"'.format(
            ts, filename, video_filters, thumbnail)
        print(cmd)
        subprocess.run(shlex.split(cmd), check=True)
        cursor.execute(
            'INSERT INTO thumbnail (movie_id, filename) VALUES (?, ?)',
            (movie_id, thumbnail.name))
    db.commit()
コード例 #5
0
def main(loc, opt):
    files = glob(os.path.join(loc, "*jpg"))
    d = tempfile.mkdtemp()
    # copy all files in loc to /tmp directory
    for f in files:
        dest = os.path.join(d, os.path.basename(f))
        copyfile(f, dest)
        if opt.verbose:
            print "Copying %s" % f
    files = glob(os.path.join(d, "*jpg"))
    db = get_db()
    for f in files:
        im = Image(f)
        if opt.verbose:
            print "Inserting into the database %s" % im.filename
        pk = insert_image(im, im.filename.replace("-", " "), None, True)
        for i in xrange(random.randint(0, 100)):
            curs = db.execute(
                """insert into instaclone_likes(image)
                             values(%s)""", [pk])
コード例 #6
0
ファイル: populate_db.py プロジェクト: simeonf/instaclone
def main(loc, opt):
    files = glob(os.path.join(loc, "*jpg"))
    d = tempfile.mkdtemp()
    # copy all files in loc to /tmp directory
    for f in files:
        dest = os.path.join(d, os.path.basename(f))
        copyfile(f, dest)
        if opt.verbose:
            print "Copying %s" % f
    files = glob(os.path.join(d, "*jpg"))
    db = get_db()
    for f in files:
        im = Image(f)
        if opt.verbose:
            print "Inserting into the database %s" % im.filename
        pk = insert_image(im, im.filename.replace("-", " "), None, True)
        for i in xrange(random.randint(0, 100)):
            curs = db.execute(
                """insert into instaclone_likes(image)
                             values(%s)""",
                [pk],
            )
コード例 #7
0
ファイル: position1.py プロジェクト: QRAAT/sim
def test1(): 

  import time
  
  cal_id = 3
  dep_id = 105
  t_start = 1407452400 
  t_end = 1407455985 - (59 * 60) 

  db_con = util.get_db('reader')
  sv = signal1.SteeringVectors(db_con, cal_id)
  signal = signal1.Signal(db_con, dep_id, t_start, t_end)

  sites = util.get_sites(db_con)
  (center, zone) = util.get_center(db_con)
  assert zone == util.get_utm_zone(db_con)
  
  start = time.time()
  pos = PositionEstimator(dep_id, sites, center, signal, sv, 
    method=signal1.Signal.MLE)
  print "Finished in {0:.2f} seconds.".format(time.time() - start)
 
  print compute_conf(pos.p, pos.num_sites, sites, pos.splines)