问题:之前未使用cv_lite库时,使用image.binary获得测试好的阈值thresholds元组列表后,调用image.find_blobs使用配套的thresholds元组列表值寻找块,配合使用正常:
image.binary(thresholds[, invert=False[, zero=False[, mask=None]]])
根据指定的阈值列表 thresholds,将图像中的所有像素转换为黑白二值图像。
thresholds:为一个元组列表,格式为 [(lo, hi), ...]。对于灰度图像,每个元组定义一个灰度值范围(最低值和最高值);对于 RGB565 图像,每个元组包含六个值,分别表示 LAB 空间中 L、A 和 B 通道的范围。
image.find_blobs(thresholds[, invert=False[, roi[, x_stride=2[, y_stride=1[, area_threshold=10[, pixels_threshold=10[, merge=False[, margin=0[, threshold_cb=None[, merge_cb=None]]]]]]]]]])
其中参数 thresholds 必须为元组列表,形式为 [(lo, hi), (lo, hi), ...],用于定义需要追踪的颜色范围。对于灰度图像,每个元组应包含两个值:最小灰度值和最大灰度值。函数将仅考虑落在这些阈值之间的像素区域。对于 RGB565 图像,每个元组需要包含六个值 (l_lo, l_hi, a_lo, a_hi, b_lo, b_hi),分别对应 LAB 色彩空间中的 L、A 和 B 通道的最小和最大值。
使用cv_lite库后,使用cv_lite.rgb888_threshold_binary获得测试好的阈值为单个int值,而函数cv_lite.rgb888_find_blobs使用的还是元组列表值:
thresh = 130 # 阈值 / Threshold value
maxval = 255 # 最大值,二值化后白色像素值 / Max value for white pixels
binary_np = cv_lite.rgb888_threshold_binary(image_shape, img_np, thresh, maxval)
threshold = [120, 255, 0, 50, 0, 50]
min_area = 100 # 最小色块面积 / Minimum blob area
kernel_size = 1 # 腐蚀膨胀核大小(用于预处理)/ Kernel size for morphological ops
调用 cv_lite 扩展进行色块检测,返回 [x, y, w, h, ...] 列表
blobs = cv_lite.rgb888_find_blobs(image_shape, img_np, threshold, min_area, kernel_size)
期待结果和实际结果
:是否有和rgb888_find_blobs其配套的函数来获取LAB的thresholds元组列表值呢?或者配套使用的这个思路是否正确?
软硬件版本信息
:CanMV v1.3-119-g79968f7(based on Micropython e00a144) on 2025-08-04; k230_canmv_01studio with K230