from __future__ import division import os, sys, cv2, random, copy import numpy as np from math import * sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../")) from ParticleFilter import particles from dataRead import readMat, normalize from config import data_config from utils import motionFCN, gradient_1, gradient_2, resample2, resample1, gradient_1_bk, gradient_2_bk, average_gradient from matplotlib import pyplot as plt from Propagation import propagation # prepare data & choose arbitary dimension data_path = os.path.join(data_config['root_dir'], data_config['data_name']) data = readMat(data_path) # data = normalize(data) # if data is canoe but not standard data = data.transpose() Dims, Length = data.shape print(Dims, Length) ''' use first several frames to generate the particles assume does not know the future frames ''' training_stage = [0, 50] # dim = 7 dim = int(random.random() * Dims) data_mean = np.mean(data[dim, :])
import os, sys, cv2, random, copy import numpy as np from math import * sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../")) from ParticleFilter import particles from dataRead import readMat, normalize from config import data_config from utils import motionFCN, gradient_1, gradient_2, resample2, resample1, gradient_1_bk, gradient_2_bk, average_gradient from matplotlib import pyplot as plt from Propagation import propagation # prepare data & choose arbitary dimension data_path = os.path.join(data_config['root_dir'], data_config['data_name']) data = normalize(readMat(data_path)) # print(data.shape) Dims, Length = data.shape # dim = 7 dim = int(random.random() * Dims) data_mean = np.mean(data[dim, :]) # highlight pred_range = [64, 74] # init 100 particles N = 100 P = [] Estimation = []
from math import * import random, os, sys sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../")) from dataRead import readMat, normalize from config import data_config from utils import motionFCN, gradient_1, gradient_2, resample2, resample1 import numpy as np import matplotlib.pyplot as plt from ParticleFilter import particles if __name__ == '__main__': # prepare data & choose arbitary dimension data_path = os.path.join(data_config['root_dir'], data_config['data_name']) measurements = normalize(readMat(data_path)) print(measurements.shape) Dims, Length = measurements.shape # dim = 7 dim = int(random.random() * Dims) data_mean = np.mean(measurements[dim, :]) # init 100 particles N = 50 P = [] Estimation = [] for i in range(N): x = particles() x.set(random.gauss(data_mean, 0.2), 0.005, 5.0, 1)