Skip to content

Commit

Permalink
fix out_of_index
Browse files Browse the repository at this point in the history
  • Loading branch information
as6325400 committed Jun 6, 2024
1 parent 6611d00 commit 407a6d1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 22 deletions.
11 changes: 7 additions & 4 deletions Qart/img.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ def module_based_binarization(cls, img, modulenums):
# assign給整個subimage,即Module
for i in range(img_size // subimage_size):
for j in range(img_size // subimage_size):
region = img[i*subimage_size:(i+1)*subimage_size,
j*subimage_size:(j+1)*subimage_size]
value = np.round(np.sum(region * gaussian_kernel) / 255)
binary_img[i][j] = value * 255
try:
region = img[i*subimage_size:(i+1)*subimage_size,
j*subimage_size:(j+1)*subimage_size]
value = np.round(np.sum(region * gaussian_kernel) / 255)
binary_img[i][j] = value * 255
except:
pass

if modulenums > len(binary_img):
## copilot 寫的 不知道能不能動
Expand Down
Binary file added tests/img2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions tests/test_qart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest
import os
from Qart import Qart
import shutil

def test_qrcode(tmpdir):
Qr = Qart('accept')
# 资源目录中的文件路径
resource_dir = "tests"
resource_file = "img2.jpeg"
resource_path = os.path.join(resource_dir, resource_file)
temp_file = tmpdir.join(resource_file)
shutil.copy(resource_path, str(temp_file))
Qr.generate(temp_file, 20, "L", mask = 0, mode = "Normal")
Qr.show()





18 changes: 0 additions & 18 deletions tests/test_qrcode.py

This file was deleted.

0 comments on commit 407a6d1

Please sign in to comment.