23 from SimpleCV
import Camera
26 from time
import sleep
29 if sys.version_info[0] == 3:
37 img = cam.getImage().scale(400,400)
43 img1 = img.binarize(int(i))
45 countW = np.count_nonzero(mat);
46 countB = mat.size-countW
47 return ((countW-countB)/float(mat.size))**2
50 params[
'n_iterations'] = 15
51 params[
'n_init_samples'] = 5
53 valid_values = np.transpose(np.array(range(256), dtype=float, ndmin=2))
54 mvalue, x_out, error = bayesopt.optimize_discrete(costImage,
59 img1 = img.binarize(x_out)
61 img1 = img.sideBySide(img1).sideBySide(img2)
62 img1.drawText(
"Threshold: "+str(x_out))
65 foo = raw_input(
'Press any key')