mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
commit
32acc9cb4e
@ -568,111 +568,6 @@ void imlib_xnor(image_t *img, const char *path, image_t *other)
|
||||
imlib_image_operation(img, path, other, imlib_xnor_line_op);
|
||||
}
|
||||
|
||||
int imlib_pixels(image_t *img, rectangle_t *r)
|
||||
{
|
||||
rectangle_t rect;
|
||||
if (!rectangle_subimg(img, r, &rect)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sum = 0;
|
||||
if (IM_IS_GS(img)) {
|
||||
for (int i = 0; i < rect.h; i++) {
|
||||
for (int j = 0; j < rect.w; j++) {
|
||||
sum += !!IM_GET_GS_PIXEL(img, (rect.x + j), (rect.y + i));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < rect.h; i++) {
|
||||
for (int j = 0; j < rect.w; j++) {
|
||||
sum += !!IM_GET_RGB565_PIXEL(img, (rect.x + j), (rect.y + i));
|
||||
}
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
int imlib_centroid(image_t *img, int *x_center, int *y_center, rectangle_t *r)
|
||||
{
|
||||
rectangle_t rect;
|
||||
if (!rectangle_subimg(img, r, &rect)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sum = 0, x_sum = 0, y_sum = 0;
|
||||
if (IM_IS_GS(img)) {
|
||||
for (int i = 0; i < rect.h; i++) {
|
||||
for (int j = 0; j < rect.w; j++) {
|
||||
int x = (rect.x + j);
|
||||
int y = (rect.y + i);
|
||||
if(IM_GET_GS_PIXEL(img, x, y)) {
|
||||
sum += 1;
|
||||
x_sum += x;
|
||||
y_sum += y;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < rect.h; i++) {
|
||||
for (int j = 0; j < rect.w; j++) {
|
||||
int x = (rect.x + j);
|
||||
int y = (rect.y + i);
|
||||
if(IM_GET_RGB565_PIXEL(img, x, y)) {
|
||||
sum += 1;
|
||||
x_sum += x;
|
||||
y_sum += y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*x_center = sum ? (x_sum / sum) : 0;
|
||||
*y_center = sum ? (y_sum / sum) : 0;
|
||||
return sum;
|
||||
}
|
||||
|
||||
float imlib_orientation_radians(image_t *img, int *sum, int *x_center, int *y_center, rectangle_t *r)
|
||||
{
|
||||
rectangle_t rect;
|
||||
if (!rectangle_subimg(img, r, &rect)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*sum = imlib_centroid(img, x_center, y_center, r);
|
||||
int a = 0, b = 0, c = 0;
|
||||
if (IM_IS_GS(img)) {
|
||||
for (int i = 0; i < rect.h; i++) {
|
||||
for (int j = 0; j < rect.w; j++) {
|
||||
int x = (rect.x + j);
|
||||
int y = (rect.y + i);
|
||||
if(IM_GET_GS_PIXEL(img, x, y)) {
|
||||
a += (x - *x_center) * (x - *x_center);
|
||||
b += (x - *x_center) * (y - *y_center);
|
||||
c += (y - *y_center) * (y - *y_center);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < rect.h; i++) {
|
||||
for (int j = 0; j < rect.w; j++) {
|
||||
int x = (rect.x + j);
|
||||
int y = (rect.y + i);
|
||||
if(IM_GET_RGB565_PIXEL(img, x, y)) {
|
||||
a += (x - *x_center) * (x - *x_center);
|
||||
b += (x - *x_center) * (y - *y_center);
|
||||
c += (y - *y_center) * (y - *y_center);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
b *= 2;
|
||||
return ((a!=c) ? fast_atan2f(b, a-c) : 0.0) / 2.0;
|
||||
}
|
||||
|
||||
float imlib_orientation_degrees(image_t *img, int *sum, int *x_center, int *y_center, rectangle_t *r)
|
||||
{
|
||||
return (imlib_orientation_radians(img, sum, x_center, y_center, r) * 180.0) / M_PI;
|
||||
}
|
||||
|
||||
static void imlib_erode_dilate(image_t *img, int ksize, int threshold, int e_or_d)
|
||||
{
|
||||
int brows = ksize + 1;
|
||||
@ -818,92 +713,6 @@ void imlib_difference(image_t *img, const char *path, image_t *other)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef OPENMV1
|
||||
void imlib_threshold(image_t *src, image_t *dst, color_t *color, int color_size, int threshold)
|
||||
{
|
||||
struct color rgb, lab;
|
||||
// Square the threshold to avoid sqrt
|
||||
threshold *= threshold;
|
||||
|
||||
// Convert the RGB888 color list to LAB
|
||||
for (int c=0; c<color_size; c++) {
|
||||
rgb.r = color[c].r;
|
||||
rgb.g = color[c].g;
|
||||
rgb.b = color[c].b;
|
||||
imlib_rgb_to_lab(&rgb, &color[c]);
|
||||
}
|
||||
|
||||
// Source image is RGB565 (2BPP)
|
||||
uint16_t *pixels = (uint16_t*) src->pixels;
|
||||
|
||||
for (int y=0; y<src->h; y++) {
|
||||
int i=y*src->w;
|
||||
for (int x=0; x<src->w; x++) {
|
||||
uint32_t p = pixels[i+x];
|
||||
rgb.r = ((p>>3)&0x1F)*255/31;
|
||||
rgb.g = ((p&0x07)<<3)|(p>>13)*255/63;
|
||||
rgb.b = ((p>>8)&0x1F)*255/31;
|
||||
imlib_rgb_to_lab(&rgb, &lab);
|
||||
|
||||
dst->pixels[i+x] = 0;
|
||||
for (int c=0; c<color_size; c++) {
|
||||
uint32_t sum =(color[c].L-lab.L) * (color[c].L-lab.L) +
|
||||
(color[c].A-lab.A) * (color[c].A-lab.A) +
|
||||
(color[c].B-lab.B) * (color[c].B-lab.B);
|
||||
if (sum<threshold) {
|
||||
// Set pixel if within threshold
|
||||
// use color index as label (c+1)
|
||||
dst->pixels[i+x] = c+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void imlib_threshold(image_t *src, image_t *dst, color_t *color, int color_size, int threshold)
|
||||
{
|
||||
// Square the threshold to avoid sqrt
|
||||
threshold *= threshold;
|
||||
|
||||
// Convert the RGB888 color list to LAB
|
||||
for (int c=0; c<color_size; c++) {
|
||||
uint16_t r = color[c].r*31/255;
|
||||
uint16_t g = color[c].g*63/255;
|
||||
uint16_t b = color[c].b*31/255;
|
||||
uint32_t rgb = IM_SWAP16((r << 11) | (g << 5) | b) * 3;
|
||||
|
||||
color[c].L = lab_table[rgb];
|
||||
color[c].A = lab_table[rgb+1];
|
||||
color[c].B = lab_table[rgb+2];
|
||||
}
|
||||
|
||||
// Source image is RGB565 (2BPP)
|
||||
uint16_t *pixels = (uint16_t*) src->pixels;
|
||||
|
||||
for (int y=0; y<src->h; y++) {
|
||||
int i=y*src->w;
|
||||
for (int x=0; x<src->w; x++) {
|
||||
// multiply by 3 to get the LAB table index
|
||||
uint32_t rgb = pixels[i+x]*3;
|
||||
dst->pixels[i+x] = 0;
|
||||
for (int c=0; c<color_size; c++) {
|
||||
// TODO optimize
|
||||
uint32_t sum =(color[c].L-lab_table[rgb]) * (color[c].L-lab_table[rgb]) +
|
||||
(color[c].A-lab_table[rgb+1]) * (color[c].A-lab_table[rgb+1]) +
|
||||
(color[c].B-lab_table[rgb+2]) * (color[c].B-lab_table[rgb+2]);
|
||||
if (sum<threshold) {
|
||||
// Set pixel if within threshold
|
||||
// use color index as label (c+1)
|
||||
dst->pixels[i+x] = c+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void imlib_rainbow(image_t *src, image_t *dst)
|
||||
{
|
||||
uint8_t *srcp = src->pixels;
|
||||
|
||||
@ -434,10 +434,6 @@ void imlib_or(image_t *img, const char *path, image_t *other);
|
||||
void imlib_nor(image_t *img, const char *path, image_t *other);
|
||||
void imlib_xor(image_t *img, const char *path, image_t *other);
|
||||
void imlib_xnor(image_t *img, const char *path, image_t *other);
|
||||
int imlib_pixels(image_t *img, rectangle_t *r);
|
||||
int imlib_centroid(image_t *img, int *x_center, int *y_center, rectangle_t *r);
|
||||
float imlib_orientation_radians(image_t *img, int *sum, int *x_center, int *y_center, rectangle_t *r);
|
||||
float imlib_orientation_degrees(image_t *img, int *sum, int *x_center, int *y_center, rectangle_t *r);
|
||||
void imlib_erode(image_t *img, int ksize, int threshold);
|
||||
void imlib_dilate(image_t *img, int ksize, int threshold);
|
||||
|
||||
@ -468,7 +464,6 @@ array_t *cluster_kmeans(array_t *points, int k);
|
||||
/* Image filtering functions */
|
||||
int imlib_image_mean(struct image *src);
|
||||
void imlib_histeq(struct image *src);
|
||||
void imlib_threshold(image_t *src, image_t *dst, color_t *color, int color_size, int threshold);
|
||||
void imlib_rainbow(image_t *src, struct image *dst);
|
||||
|
||||
/* Integral image functions */
|
||||
|
||||
@ -518,62 +518,6 @@ static mp_obj_t py_image_xnor(mp_obj_t img_obj, mp_obj_t other_obj)
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
static mp_obj_t py_image_pixels(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
PY_ASSERT_FALSE_MSG(IM_IS_JPEG(arg_img),
|
||||
"Operation not supported on JPEG");
|
||||
|
||||
rectangle_t arg_r;
|
||||
py_helper_lookup_rectangle(kw_args, arg_img, &arg_r);
|
||||
return mp_obj_new_int(imlib_pixels(arg_img, &arg_r));
|
||||
}
|
||||
|
||||
static mp_obj_t py_image_centroid(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
PY_ASSERT_FALSE_MSG(IM_IS_JPEG(arg_img),
|
||||
"Operation not supported on JPEG");
|
||||
|
||||
rectangle_t arg_r;
|
||||
py_helper_lookup_rectangle(kw_args, arg_img, &arg_r);
|
||||
int x = 0, y = 0;
|
||||
int sum = imlib_centroid(arg_img, &x, &y, &arg_r);
|
||||
|
||||
return mp_obj_new_tuple(3, (mp_obj_t[3])
|
||||
{mp_obj_new_int(sum), mp_obj_new_int(x), mp_obj_new_int(y)});
|
||||
}
|
||||
|
||||
static mp_obj_t py_image_orientation_radians(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
PY_ASSERT_FALSE_MSG(IM_IS_JPEG(arg_img),
|
||||
"Operation not supported on JPEG");
|
||||
|
||||
rectangle_t arg_r;
|
||||
py_helper_lookup_rectangle(kw_args, arg_img, &arg_r);
|
||||
int sum = 0, x = 0, y = 0;
|
||||
float o = imlib_orientation_radians(arg_img, &sum, &x, &y, &arg_r);
|
||||
|
||||
return mp_obj_new_tuple(4, (mp_obj_t[4])
|
||||
{mp_obj_new_int(sum), mp_obj_new_int(x), mp_obj_new_int(y), mp_obj_new_float(o)});
|
||||
}
|
||||
|
||||
static mp_obj_t py_image_orientation_degrees(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
PY_ASSERT_FALSE_MSG(IM_IS_JPEG(arg_img),
|
||||
"Operation not supported on JPEG");
|
||||
|
||||
rectangle_t arg_r;
|
||||
py_helper_lookup_rectangle(kw_args, arg_img, &arg_r);
|
||||
int sum = 0, x = 0, y = 0;
|
||||
float o = imlib_orientation_degrees(arg_img, &sum, &x, &y, &arg_r);
|
||||
|
||||
return mp_obj_new_tuple(4, (mp_obj_t[4])
|
||||
{mp_obj_new_int(sum), mp_obj_new_int(x), mp_obj_new_int(y), mp_obj_new_float(o)});
|
||||
}
|
||||
|
||||
static mp_obj_t py_image_erode(uint n_args, const mp_obj_t *args, mp_map_t *kw_args)
|
||||
{
|
||||
image_t *arg_img = py_image_cobj(args[0]);
|
||||
@ -968,51 +912,6 @@ static mp_obj_t py_image_histeq(mp_obj_t image_obj)
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
static mp_obj_t py_image_threshold(mp_obj_t image_obj, mp_obj_t color_list_obj, mp_obj_t threshold)
|
||||
{
|
||||
color_t *color;
|
||||
image_t *image;
|
||||
|
||||
/* sanity checks */
|
||||
PY_ASSERT_TRUE_MSG(sensor.pixformat == PIXFORMAT_RGB565,
|
||||
"This function is only supported on RGB565 images");
|
||||
|
||||
PY_ASSERT_TRUE_MSG(sensor.framesize <= OMV_MAX_BLOB_FRAME,
|
||||
"This function is only supported on "OMV_MAX_BLOB_FRAME_STR" and smaller frames");
|
||||
|
||||
/* read arguments */
|
||||
image = py_image_cobj(image_obj);
|
||||
int thresh = mp_obj_get_int(threshold);
|
||||
|
||||
/* returned image */
|
||||
image_t bimage = {
|
||||
.w=image->w,
|
||||
.h=image->h,
|
||||
.bpp=1,
|
||||
.pixels=image->data+(image->w*image->h*image->bpp)
|
||||
};
|
||||
|
||||
/* copy color list */
|
||||
uint len;
|
||||
mp_obj_t *color_arr;
|
||||
mp_obj_get_array(color_list_obj, &len, &color_arr);
|
||||
|
||||
color = xalloc(len*sizeof*color);
|
||||
|
||||
for (int i=0; i<len; i++) {
|
||||
mp_obj_t *color_obj;
|
||||
mp_obj_get_array_fixed_n(color_arr[i], 3, &color_obj);
|
||||
color[i].r = mp_obj_get_int(color_obj[0]);
|
||||
color[i].g = mp_obj_get_int(color_obj[1]);
|
||||
color[i].b = mp_obj_get_int(color_obj[2]);
|
||||
}
|
||||
|
||||
/* Threshold image using reference color */
|
||||
imlib_threshold(image, &bimage, color, len, thresh);
|
||||
|
||||
return py_image_from_struct(&bimage);
|
||||
}
|
||||
|
||||
static mp_obj_t py_image_rainbow(mp_obj_t src_image_obj)
|
||||
{
|
||||
image_t *src_image = NULL;
|
||||
@ -1256,10 +1155,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_or_obj, py_image_or);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_nor_obj, py_image_nor);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_xor_obj, py_image_xor);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_xnor_obj, py_image_xnor);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_pixels_obj, 1, py_image_pixels);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_centroid_obj, 1, py_image_centroid);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_orientation_radians_obj, 1, py_image_orientation_radians);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_orientation_degrees_obj, 1, py_image_orientation_degrees);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_erode_obj, 2, py_image_erode);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_image_dilate_obj, 2, py_image_dilate);
|
||||
/* Background Subtraction (Frame Differencing) functions */
|
||||
@ -1284,7 +1179,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_subimg_obj, py_image_subimg);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_blit_obj, py_image_blit);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_blend_obj, py_image_blend);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_histeq_obj, py_image_histeq);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_3(py_image_threshold_obj, py_image_threshold);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(py_image_rainbow_obj, py_image_rainbow);
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(py_image_compress_obj, py_image_compress);
|
||||
|
||||
@ -1320,10 +1214,6 @@ static const mp_map_elem_t locals_dict_table[] = {
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_nor), (mp_obj_t)&py_image_nor_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_xor), (mp_obj_t)&py_image_xor_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_xnor), (mp_obj_t)&py_image_xnor_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_pixels), (mp_obj_t)&py_image_pixels_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_centroid), (mp_obj_t)&py_image_centroid_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_orientation_radians), (mp_obj_t)&py_image_orientation_radians_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_orientation_degrees), (mp_obj_t)&py_image_orientation_degrees_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_erode), (mp_obj_t)&py_image_erode_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_dilate), (mp_obj_t)&py_image_dilate_obj},
|
||||
/* Background Subtraction (Frame Differencing) functions */
|
||||
@ -1348,7 +1238,6 @@ static const mp_map_elem_t locals_dict_table[] = {
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_blit), (mp_obj_t)&py_image_blit_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_blend), (mp_obj_t)&py_image_blend_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_histeq), (mp_obj_t)&py_image_histeq_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_threshold), (mp_obj_t)&py_image_threshold_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_rainbow), (mp_obj_t)&py_image_rainbow_obj},
|
||||
{MP_OBJ_NEW_QSTR(MP_QSTR_compress), (mp_obj_t)&py_image_compress_obj},
|
||||
/* objects/feature detection */
|
||||
|
||||
@ -44,10 +44,6 @@ Q(or)
|
||||
Q(nor)
|
||||
Q(xor)
|
||||
Q(xnor)
|
||||
Q(pixels)
|
||||
Q(centroid)
|
||||
Q(orientation_radians)
|
||||
Q(orientation_degrees)
|
||||
Q(erode)
|
||||
Q(dilate)
|
||||
Q(negate)
|
||||
@ -70,7 +66,6 @@ Q(subimg)
|
||||
Q(compress)
|
||||
Q(rainbow)
|
||||
Q(histeq)
|
||||
Q(threshold)
|
||||
Q(find_template)
|
||||
Q(find_features)
|
||||
Q(find_keypoints)
|
||||
@ -79,6 +74,7 @@ Q(find_eyes)
|
||||
Q(cmp_lbp)
|
||||
Q(color)
|
||||
Q(roi)
|
||||
Q(threshold)
|
||||
Q(mul)
|
||||
Q(add)
|
||||
Q(bias)
|
||||
|
||||
@ -33,10 +33,10 @@ while(True):
|
||||
while(diff):
|
||||
img = sensor.snapshot()
|
||||
img.difference("temp/bg.bmp")
|
||||
img.binary([(20, 100, -128, 127, -128, 127)])
|
||||
sum = img.pixels()
|
||||
if sum > 100: # Over 100 pixels need to change to detect motion.
|
||||
diff -= 1
|
||||
for blob_l in img.find_blobs([(20, 100, -128, 127, -128, 127)]):
|
||||
for blob in blob_l:
|
||||
# Over 100 pixels need to change to detect motion.
|
||||
if (diff and (blob[4] > 100)): diff -= 1
|
||||
|
||||
pyb.LED(BLUE_LED_PIN).off()
|
||||
print("Movement detected! Saving image...")
|
||||
|
||||
@ -37,10 +37,10 @@ while(True):
|
||||
while(diff):
|
||||
img = sensor.snapshot()
|
||||
img.difference("temp/bg.bmp")
|
||||
img.binary([(20, 100, -128, 127, -128, 127)])
|
||||
sum = img.pixels()
|
||||
if sum > 100: # Over 100 pixels need to change to detect motion.
|
||||
diff -= 1
|
||||
for blob_l in img.find_blobs([(20, 100, -128, 127, -128, 127)]):
|
||||
for blob in blob_l:
|
||||
# Over 100 pixels need to change to detect motion.
|
||||
if (diff and (blob[4] > 100)): diff -= 1
|
||||
|
||||
g = gif.Gif("example-%d.gif" % pyb.rng(), loop=True)
|
||||
|
||||
|
||||
@ -38,10 +38,10 @@ while(True):
|
||||
while(diff):
|
||||
img = sensor.snapshot()
|
||||
img.difference("temp/bg.bmp")
|
||||
img.binary([(20, 100, -128, 127, -128, 127)])
|
||||
sum = img.pixels()
|
||||
if sum > 100: # Over 100 pixels need to change to detect motion.
|
||||
diff -= 1
|
||||
for blob_l in img.find_blobs([(20, 100, -128, 127, -128, 127)]):
|
||||
for blob in blob_l:
|
||||
# Over 100 pixels need to change to detect motion.
|
||||
if (diff and (blob[4] > 100)): diff -= 1
|
||||
|
||||
m = mjpeg.Mjpeg("example-%d.mjpeg" % pyb.rng())
|
||||
|
||||
|
||||
@ -9,23 +9,15 @@ while(True):
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([low_threshold])
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = 127, size = 20)
|
||||
# Test high threshold
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([high_threshold])
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = 127, size = 20)
|
||||
# Test not low threshold
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([low_threshold], invert = 1)
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = 127, size = 20)
|
||||
# Test not high threshold
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([high_threshold], invert = 1)
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = 127, size = 20)
|
||||
|
||||
@ -10,35 +10,23 @@ while(True):
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([red_threshold])
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = (255, 0, 0), size = 20)
|
||||
# Test green threshold
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([green_threshold])
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = (0, 255, 0), size = 20)
|
||||
# Test blue threshold
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([blue_threshold])
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = (0, 0, 255), size = 20)
|
||||
# Test not red threshold
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([red_threshold], invert = 1)
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = (255, 0, 0), size = 20)
|
||||
# Test not green threshold
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([green_threshold], invert = 1)
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = (0, 255, 0), size = 20)
|
||||
# Test not blue threshold
|
||||
for i in range(100):
|
||||
img = sensor.snapshot()
|
||||
img.binary([blue_threshold], invert = 1)
|
||||
sum, x, y, rads = img.orientation_radians()
|
||||
img.draw_keypoints([(x, y, rads)], color = (0, 0, 255), size = 20)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user