예제 #1
0
	def run_test(image, position, shape, block_size):
		code = Code()
		out_reg = code.alloc_reg()
		def code_gen(code, block_size, args): 
			return gen_code.gen_integral_sum(code, out_reg, position, shape, ptr, block_size)
		code.set_generator(optimiser_wrapper(code_gen), block_size)

		sim = Interpreter(code, image, block_size)
		sim.run()
		# extract value
		return sim.procs[0][0].get_reg_by_name(str(out_reg))
예제 #2
0
	def run_test(position, integral_test, sq_integral_test, haar_size, block_size):
		integral_ptr = 0
		sq_integral_ptr = block_size[0]*block_size[1]

		code = Code()
		out_reg = code.alloc_reg()
		def code_gen(code, block_size, args):
			return gen_code.gen_calc_variance(code, out_reg, position, integral_ptr, sq_integral_ptr, haar_size, block_size)
		code.set_generator(optimiser_wrapper(code_gen), block_size)

		sim = Interpreter(code, integral_test, block_size)
		# hack: in order to avoid calculating integral images, inject random values into the sq_integral buffer
		# this is easy since their is only a single PE
		for i, row in enumerate(sq_integral_test):
			for j, v in enumerate(row):
				sim.procs[0][0].memory.set(sq_integral_ptr + len(row)*i+j, v)

		sim.run()

		pe = sim.procs[0][0]
		# extract value
		return (1./(pe.get_reg_by_name(str(out_reg)))), pe