少了函数参数?但不知道少了什么
-
代码:
blobs_threshold = [(240, 255)]
blobs_pixels_threshold = 300
blobs_area_threshold = 600
blob_list = img.find_blobs(threshold = blobs_threshold,pixels_threshold = blobs_pixels_threshold, area_threshold = blobs_area_threshold, merge=True)报错信息:
TypeError: function missing 1 required positional arguments以上,为涉及到的代码部分,希望能得到解决,已经看过相关例程。
-
需要全部的代码文本,否则我没办法测试。
-
代碼:
# Untitled - By: goushi - Thu Jul 11 2024 import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) blobs_threshold = [(240, 255)] blobs_pixels_threshold = 300 blobs_area_threshold = 600 clock = time.clock() while(True): clock.tick() img = sensor.snapshot().lens_corr(1.8) blob_list = img.find_blobs(threshold = blobs_threshold,pixels_threshold = blobs_pixels_threshold, area_threshold = blobs_area_threshold, merge=True) for blob in blob_list: img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) print(clock.fps())
報錯信息:
Traceback (most recent call last): File "<stdin>", line 17, in <module> TypeError: function missing 1 required positional arguments
-
少了代碼 我再重發一下
# Untitled - By: goushi - Thu Jul 11 2024 import sensor, image, time sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QVGA) sensor.skip_frames(time = 2000) gray_binary_threshold = [(50, 80)]# 边缘检测算法的阈值控制 blobs_threshold = [(240, 255)] blobs_pixels_threshold = 300 blobs_area_threshold = 600 clock = time.clock() while(True): clock.tick() img = sensor.snapshot().lens_corr(1.8) img.to_grayscale() # 转化为二值化黑白图 img.to_bitmap(thresholds = gray_binary_threshold, invert = False) blob_list = img.find_blobs(threshold = blobs_threshold,pixels_threshold = blobs_pixels_threshold, area_threshold = blobs_area_threshold, merge=True) for blob in blob_list: img.draw_rectangle(blob.rect()) img.draw_cross(blob.cx(), blob.cy()) print(clock.fps())
報錯信息:
Traceback (most recent call last): File "<stdin>", line 21, in <module> TypeError: function missing 1 required positional arguments
-
@kidswong999 感謝回復,已附上全部代碼,期待您的回復。
-
21行,改为:blob_list = img.find_blobs(blobs_threshold, pixels_threshold = blobs_pixels_threshold, area_threshold = blobs_area_threshold, merge=True)