Z-AnyLabeling标注工具

1.使用yolo系列模型时,首先要标注图片,网上查看了一些标注的工具,很多都不是离线运行,或者功能复杂不适合使用。
2.查看了一款开源的标注软件AnyLabeling,觉得功能很多,导出的数据格式是.json,没有直接跟yolo系列对接的数据格式。
3.为了方便,开发一款Z-AnyLabeling标注工具,具备基础功能,数据直接导出yolo系列可以训练的数据格式
4.软件开发环境:Pycharm,Pyside6
5.软件界面
请添加图片描述
6.相关代码


    '''鼠标按下'''
    def mousePressEvent(self, event: PySide6.QtGui.QMouseEvent):
        super(ControlImage, self).mousePressEvent(event)
        if ((self._current_image.width() == 0)
                & (self._current_image.height() == 0)):
            return

        if event.button()==Qt.MouseButton.LeftButton:
            self._mouse_down = True
            self._down_point = event.pos()
            self._last_point = event.pos()
            point_in_board_=self.GetPointInBoard(self._last_point)
            #找到轮廓标志
            find_shape_ = False
            #绘制矩形
            if self._control_image_oper_en==ControlImageOperEnum.DrawRectangle:
                #判断有没有选中shape
                if(len(self._shape_list)>0):
                    for i in range(len(self._shape_list)):
                            #显示的才计算计算有没有选中点
                        if self._shape_list[i]._display==True:
                            #判断有没有选中第一个点
                            point1_x_distance_=abs(self._shape_list[i]._x1-point_in_board_.x())
                            point1_y_distance_=abs(self._shape_list[i]._y1-point_in_board_.y())

                            if((point1_x_distance_<10)
                            &(point1_y_distance_<10)):
                                self._current_shape_list_oper_point=1
                                self._current_shape_list_index=i
                                find_shape_ = True
                                i=len(self._shape_list)

                            #有没有选中第二个点
                            if(find_shape_==False):
                                point2_x_distance_=abs(self._shape_list[i]._x2-point_in_board_.x())
                                point2_y_distance_=abs(self._shape_list[i]._y2-point_in_board_.y())
                                if((point2_x_distance_<10)
                                &(point2_y_distance_<10)):
                                    self._current_shape_list_oper_point = 2
                                    self._current_shape_list_index = i
                                    find_shape_ = True
                                    i = len(self._shape_list)

                            #有没有选中第三个点
                            if(find_shape_==False):
                                if((point_in_board_.x()>self._shape_list[i]._x1)
                                    &(point_in_board_.x()<self._shape_list[i]._x2)
                                    &(point_in_board_.y()>self._shape_list[i]._y1)
                                    &(point_in_board_.y()<self._shape_list[i]._y2)):

                                    self._current_shape_list_oper_point = 3
                                    self._current_shape_list_index = i
                                    find_shape_ = True
                                    i = len(self._shape_list)
                if ((find_shape_ == False)
                        &(self._current_label!="")):
                    self._current_shape=Shape()
                    self._current_shape._display=True
                    self._current_shape._x1=point_in_board_.x()
                    self._current_shape._y1=point_in_board_.y()
                    self._current_shape._x2 = point_in_board_.x()
                    self._current_shape._y2 = point_in_board_.y()
                    self._current_shape._id=len(self._shape_list)
                    self._current_shape._label=self._current_label
                    #刷新一下
                    self.update()
            #删除矩形
            elif self._control_image_oper_en==ControlImageOperEnum.DeleteRectangle:
                if (len(self._shape_list) > 0):
                    for i in range(len(self._shape_list)):
                        # 显示的才计算计算有没有选中点
                        if self._shape_list[i]._display == True:
                            #有没有选中第三个点
                            if ((point_in_board_.x() > self._shape_list[i]._x1)
                                    & (point_in_board_.x() < self._shape_list[i]._x2)
                                    & (point_in_board_.y() > self._shape_list[i]._y1)
                                    & (point_in_board_.y() < self._shape_list[i]._y2)):
                                del self._shape_list[i]
                                find_shape_ = True
                                i = self._shape_list.__len__()
                                # 判断有没有形状
                                if (i == 0):
                                    self._updata_image_shape_exist_status_sig.emit(False)

                    if find_shape_==True:
                        self.update()
            #修改标签
            elif self._control_image_oper_en==ControlImageOperEnum.ModificalLabel:
                if (len(self._shape_list) > 0):
                    for i in range(len(self._shape_list)):
                        # 显示的才计算计算有没有选中点
                        if self._shape_list[i]._display == True:
                            if ((point_in_board_.x() > self._shape_list[i]._x1)
                                    & (point_in_board_.x() < self._shape_list[i]._x2)
                                    & (point_in_board_.y() > self._shape_list[i]._y1)
                                    & (point_in_board_.y() < self._shape_list[i]._y2)):
                                self._shape_list[i]._label=self._current_label
                                find_shape_ = True
                                i = self._shape_list.__len__()
                    if find_shape_==True:
                        self.update()
            #隐藏形状
            elif self._control_image_oper_en==ControlImageOperEnum.HideShape:
                if (len(self._shape_list) > 0):
                    for i in range(len(self._shape_list)):
                        # 显示的才计算计算有没有选中点
                        if self._shape_list[i]._display == True:
                            if ((point_in_board_.x() > self._shape_list[i]._x1)
                                    & (point_in_board_.x() < self._shape_list[i]._x2)
                                    & (point_in_board_.y() > self._shape_list[i]._y1)
                                    & (point_in_board_.y() < self._shape_list[i]._y2)):
                                self._shape_list[i]._display=False
                                find_shape_ = True
                                i = self._shape_list.__len__()
                    if find_shape_==True:
                        self.update()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值