개정판 3616c8f6
issue #655: grid box single page
DTI_PID/DTI_PID/TrainingImageListDialog.py | ||
---|---|---|
318 | 318 |
trainingGridImg = Image.new("RGB", (totalGridWidth, totalGridHeight), (256,256,256)) |
319 | 319 |
|
320 | 320 |
boxCount = 0 |
321 |
outBox = "" |
|
321 | 322 |
for rowCount in range(countOfOneSide): |
322 | 323 |
for colCount in range(countOfOneSide): |
323 | 324 |
boxComponent = boxes[boxCount].split(' ') |
... | ... | |
326 | 327 |
gridW = abs(int(boxComponent[3]) - int(boxComponent[1])) |
327 | 328 |
gridH = abs(int(boxComponent[4]) - int(boxComponent[2])) |
328 | 329 |
gridBoxImg = trainingTextImg.crop((gridX, gridY, gridX + gridW, gridY + gridH)) |
329 |
trainingGridImg.paste(gridBoxImg, (colCount * maxBoxWidth, rowCount * maxBoxHeight, colCount * maxBoxWidth + gridW, rowCount * maxBoxHeight + gridH)) |
|
330 |
imagX1 = colCount * maxBoxWidth |
|
331 |
imagY1 = rowCount * maxBoxHeight |
|
332 |
imagX2 = colCount * maxBoxWidth + gridW |
|
333 |
imagY2 = rowCount * maxBoxHeight + gridH |
|
334 |
trainingGridImg.paste(gridBoxImg, (imagX1, imagY1, imagX2, imagY2)) |
|
335 |
|
|
336 |
boxX1 = imagX1 |
|
337 |
boxY1 = totalGridHeight - imagY2 |
|
338 |
boxX2 = colCount * maxBoxWidth + gridW |
|
339 |
boxY2 = totalGridHeight - imagY1 |
|
340 |
outBox += boxComponent[0] + " " + str(boxX1) + " " + str(boxY1) + " " + str(boxX2) + " " + str(boxY2) + ' 0\n' |
|
330 | 341 |
boxCount += 1 |
331 | 342 |
if boxCount == len(boxes): |
332 | 343 |
break |
... | ... | |
334 | 345 |
if boxCount == len(boxes): |
335 | 346 |
break |
336 | 347 |
trainingGridImg.save(trainingImgPath, compression='tiff_lzw') |
348 |
fw = open(trainingBoxPath, 'w', encoding='utf8') |
|
349 |
fw.write(outBox) |
|
350 |
fw.close() |
|
337 | 351 |
# 1112 |
338 | 352 |
|
339 | 353 |
self.ui.labelProgress.setText('학습 이미지 파일을 생성했습니다.') |
내보내기 Unified diff