diff --git a/README.md b/README.md index 832fb08e3aa5883bbb064c824de862795e099677..c70a02782325b0d0ba9acae142e7c79a5da38da2 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ The software has three main modules: We also provide `main.py` as a warpper for all the modules above. By runing it, you can make Farmbot automatically conduct the whole process. The three modules can also be run sperately, mostly for debugging purpose. -First go to `/src/` to run the following scripts. +First go to `/src/` and `conda activate <env>` to run the following scripts. `<env>` is the same as the one you created in *Install, Compile* ### Move Famrbot, take photos, and open/close the gripper ### YOLO detection All the arguments for file path are set to default. diff --git a/src/detect.py b/src/detect.py index 28f2fe8f7787c64d68265c92d03b55d720b58b29..acccc62fb22f742f7b50cf8ec6477c9466c3484a 100644 --- a/src/detect.py +++ b/src/detect.py @@ -120,7 +120,7 @@ def save_annotations(original_size, name, image, detections, class_names): f.write("{} {:.4f} {:.4f} {:.4f} {:.4f} {:.4f}\n".format(label, x*width, y*height, w*width, h*height, float(confidence))) -def main(): +def detect(): args = parser() check_arguments_errors(args) @@ -160,4 +160,4 @@ def main(): if __name__ == "__main__": - main() + detect() diff --git a/src/location.py b/src/location.py index 864ca95948b97d960eabb13fa087b6636b8540e0..69a8b163d5d7cda4475321241476efaeabf727b4 100644 --- a/src/location.py +++ b/src/location.py @@ -254,6 +254,7 @@ if __name__ == '__main__': parser.add_argument('-v', '--verbose', action='store_true', help='Verbose mode') arguments = parser.parse_args() + if arguments.verbose: basicConfig(filename=arguments.log, level=DEBUG) else: diff --git a/src/main.py b/src/main.py index c4d9b16c9a93fedf37cc59f677a825de4aa99820..ba5dc8adb13f7a695c6ee730ebe7458ffafa07c4 100644 --- a/src/main.py +++ b/src/main.py @@ -17,30 +17,30 @@ from location import * _Log = getLogger(__name__) -def remove_overlap(): - return +def remove_overlap(table_coordinate:DataFrame, tolerance=50.00)->DataFrame: + ''' + compare every two coordinates, if their Euclidean distance is smaller than tolerance + , delete the one with lower probability + ''' + # 这又要求重写前面的了,加入 probability + return table_coordinate # 还要定期清理掉img下所有文件 def remove_temp(): return -def choose_class(category: int) -> : - ''' - Choose the category to pick up - ''' - return - def main(args: Namespace): # scan - + scan() # detect - + detect() # calculate locations - + list_global_coordinate = cal_location() # choose class - list_global_coordinate[:, 0] - + table_global_coordinate = DataFrame(list_global_coordinate, columns=['class', 'x', 'y']) + goal_class = list_global_coordinate[table_global_coordinate['class']==args.category] + # 添加一个if判断,如果该类为空,则显示 # remove overlap # move @@ -79,8 +79,8 @@ if __name__ == '__main__': ) # arguemtns for grip parser.add_argument( - '-cl', - '--class', + '-ca', + '--category', type=str, help='Choose the class of fruits to be picked up. There are tomato, mushroom,\ potato, carrot, beetroot, zucchini, hand' diff --git a/src/move.py b/src/move.py index 5f380fad72ab352bb56a702d7e052d9a40222f4e..32efa824a47eb09562a46c8f75670dccbbe842a6 100644 --- a/src/move.py +++ b/src/move.py @@ -39,10 +39,11 @@ class Opts: self.flag = flag -def scan(min_x=0, max_x=1300, min_y=0, max_y=1000, delta=500, offset=0, flag=True) -> List: +def scan(min_x=0, max_x=1300, min_y=0, max_y=1000, delta=500, offset=0, flag=True) -> List: #里面的数字需要重新测量 ''' scan the bed at a certain height, first move along x axis, then y, like a zig zag; Taking pictures and record the location of the camera that corresponds to the picture + The default value of x, y should be from the measurement of Farmbot Input: min_x: left most point on x axis max_x: right most point on x axis min_y: front most point on y axis @@ -77,7 +78,7 @@ def scan(min_x=0, max_x=1300, min_y=0, max_y=1000, delta=500, offset=0, flag=Tru #client #需要添加一个函数,读取当前位置,需要吗? client.take_photo() # 拍照时,需要记住每张照片对应的相机位置! client.shutdown() - return pts + return pts # 这里应该写入文件 img/location def download_images() -> Path: