From 4a3a47a7c76037320f89e36383ff8d5c75d5f4f3 Mon Sep 17 00:00:00 2001 From: tzutalin Date: Tue, 6 Sep 2016 17:24:47 +0800 Subject: [PATCH] rm opencv module --- libs/labelFile.py | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/libs/labelFile.py b/libs/labelFile.py index bf984352..3bc5af10 100644 --- a/libs/labelFile.py +++ b/libs/labelFile.py @@ -1,10 +1,13 @@ -import json -import os.path -import numpy -import cv2 -import sys -from pascal_voc_io import PascalVocWriter +# Copyright (c) 2016 Tzutalin +# Create by TzuTaLin + +from PyQt4.QtGui import QImage from base64 import b64encode, b64decode +from pascal_voc_io import PascalVocWriter +import json +import numpy +import os.path +import sys class LabelFileError(Exception): pass @@ -58,9 +61,11 @@ class LabelFile(object): imgFolderName = os.path.split(imgFolderPath)[-1] imgFileName = os.path.basename(imagePath) imgFileNameWithoutExt = os.path.splitext(imgFileName)[0] - - img = cv2.imread(imagePath) - imageShape = img.shape + # Read from file path because self.imageData might be empty if saving to + # Pascal format + image = QImage() + image.load(imagePath) + imageShape = [image.height(), image.width(), 1 if image.isGrayscale() else 3] writer = PascalVocWriter(imgFolderName, imgFileNameWithoutExt,\ imageShape, localImgPath=imagePath) bSave = False