Halcon中visualize_object_model_3d算子详解

概念

此函数用于显示3d模型。该函数功能很多,包括设置位姿,颜色,鼠标翻转、缩放、平移,选择和取消选择目标,降低鼠标灵敏度,切换检查模式等。

参数

visualize_object_model_3d( : : WindowHandle, ObjectModel3D, CamParam, PoseIn, GenParamName, GenParamValue, Title, Label, Information : PoseOut)
WindowHandle:窗体标识符。
ObjectModel3D:3d模型。
CamParam:相机参数,例如:StartCamPar := [0.016, 0, 0.0000074, 0.0000074, 326, 247, 652, 494]
PoseIn:起始位姿。
GenParamName:参数名称,用于各个功能模块的调用,可随意选择。包括以下参数:‘alpha’, ‘attribute’, ‘color’, ‘colored’, ‘disp_background’, ‘disp_lines’, ‘disp_normals’, ‘disp_pose’, ‘inspection_mode’, ‘intensity’, ‘intensity_red’, ‘intensity_green’, ‘intensity_blue’, ‘light_position’, ‘light_ambient’, ‘light_diffuse’, ‘line_color’, ‘line_width’, ‘lut’, ‘max_num_selectable_models’, ‘normal_color’, ‘poi

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Mask R-CNN 是一种基于 Faster R-CNN 的目标检测算法,不仅可以检测出物体的位置,还可以精确地分割出物体的 mask。下面是一个 Mask R-CNN 的例程: ```python import os import sys import random import math import numpy as np import skimage.io import matplotlib import matplotlib.pyplot as plt # Root directory of the project ROOT_DIR = os.path.abspath("../") # Import Mask RCNN sys.path.append(ROOT_DIR) # To find local version of the library from mrcnn import utils import mrcnn.model as modellib from mrcnn import visualize from mrcnn.config import Config # Directory to save logs and trained model MODEL_DIR = os.path.join(ROOT_DIR, "logs") # Local path to trained weights file COCO_MODEL_PATH = os.path.join(ROOT_DIR, "mask_rcnn_coco.h5") # Download COCO trained weights from Releases if needed if not os.path.exists(COCO_MODEL_PATH): utils.download_trained_weights(COCO_MODEL_PATH) # Directory of images to run detection on IMAGE_DIR = os.path.join(ROOT_DIR, "images") class InferenceConfig(Config): # Set batch size to 1 since we'll be running inference on # one image at a time. Batch size = GPU_COUNT * IMAGES_PER_GPU GPU_COUNT = 1 IMAGES_PER_GPU = 1 NUM_CLASSES = 1 + 80 # COCO has 80 classes config = InferenceConfig() config.display() # Create model object in inference mode. model = modellib.MaskRCNN(mode="inference", model_dir=MODEL_DIR, config=config) # Load weights trained on MS-COCO model.load_weights(COCO_MODEL_PATH, by_name=True) # COCO Class names # Index of the class in the list is its ID. For example, to get ID of # the teddy bear class, use: class_names.index('teddy bear') class_names = ['BG', 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck', 'boat', 'traffic light', 'fire hydrant', 'stop sign', 'parking meter', 'bench', 'bird', 'cat', 'dog', 'horse', 'sheep', 'cow', 'elephant', 'bear', 'zebra', 'giraffe', 'backpack', 'umbrella', 'handbag', 'tie', 'suitcase', 'frisbee', 'skis', 'snowboard', 'sports ball', 'kite', 'baseball bat', 'baseball glove', 'skateboard', 'surfboard', 'tennis racket', 'bottle', 'wine glass', 'cup', 'fork', 'knife', 'spoon', 'bowl', 'banana', 'apple', 'sandwich', 'orange', 'broccoli', 'carrot', 'hot dog', 'pizza', 'donut', 'cake', 'chair', 'couch', 'potted plant', 'bed', 'dining table', 'toilet', 'tv', 'laptop', 'mouse', 'remote', 'keyboard', 'cell phone', 'microwave', 'oven', 'toaster', 'sink', 'refrigerator', 'book', 'clock', 'vase', 'scissors', 'teddy bear', 'hair drier', 'toothbrush'] # Load a random image from the images folder file_names = next(os.walk(IMAGE_DIR))[2] image = skimage.io.imread(os.path.join(IMAGE_DIR, random.choice(file_names))) # Run detection results = model.detect([image], verbose=1) # Visualize results r = results[0] visualize.display_instances(image, r['rois'], r['masks'], r['class_ids'], class_names, r['scores']) ``` 在上面的例程,我们首先导入所需的库和模块,包括 Mask R-CNN 的配置、模型、可视化等。然后,我们设置了模型的超参数和文件路径,以及加载了预训练的 COCO 权重。接下来,我们定义了一个 InferenceConfig 类,它继承自 Config 类,并设置了模型的 GPU 数量、每个 GPU 的图片数量和类别数。然后,我们在 inference 模式下创建了模型对象,并加载了预训练的 COCO 权重。最后,我们从图片文件夹随机加载一张图片,并对其进行目标检测和分割,最后可视化检测结果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值