Choi-Hong-Jun / OMR

omr scanning application
2 stars 0 forks source link

read_omr.py 파일 수정후 작동 오류 #18

Closed Choi-Hong-Jun closed 6 months ago

Choi-Hong-Jun commented 6 months ago
C:\Users\bjgir\PycharmProjects\pythonProject1\read_omr.py:168: RuntimeWarning: invalid value encountered in scalar divide
  return [(x - np.min(target)) / (np.max(target) - np.min(target)) for x in target]

이 오류가 발생했는 데 수정을 잘못 했을 가능성 있음

Choi-Hong-Jun commented 6 months ago
return [(x - np.min(target)) / (np.max(target) - np.min(target)) for x in target]

이 코드를

min_val = np.min(target)
max_val = np.max(target)

if min_val == max_val:
    return [0 for x in target]
else:
    return [(x - min_val) / (max_val - min_val) for x in target]

이렇게 수정했더니 아래와 같은 오류 발생

Traceback (most recent call last):
  File "C:\Users\bjgir\PycharmProjects\pythonProject1\grade.py", line 165, in uploadFile
    _name = self.omr_reader.extract_name(img, gray_img)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bjgir\PycharmProjects\pythonProject1\read_omr.py", line 45, in extract_name
    fullname.append(self.extract_each_name(img, gray, [
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bjgir\PycharmProjects\pythonProject1\read_omr.py", line 69, in extract_each_name
    omr_names.append(self._extract_name(img, gray, coordinates, _map, threshold, _type))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bjgir\PycharmProjects\pythonProject1\read_omr.py", line 126, in _extract_name
    ret = self.select_filled_loc_without_threshold(rawdat, mean_colored)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\bjgir\PycharmProjects\pythonProject1\read_omr.py", line 181, in select_filled_loc_without_threshold
    min2 = sorted(mm)[1]
           ~~~~~~~~~~^^^
IndexError: list index out of range
ktiberius commented 6 months ago

아하 문제 발생한 pdf가 어떤거야 ?

d64ec9d15252b81fc3e4c43a9b3b4dc2e5e306ee 는 이것 때문에 수정 ?

ktiberius commented 6 months ago
C:\Users\bjgir\PycharmProjects\pythonProject1\read_omr.py:168: RuntimeWarning: invalid value encountered in scalar divide
  return [(x - np.min(target)) / (np.max(target) - np.min(target)) for x in target]

이 오류가 발생했는 데 수정을 잘못 했을 가능성 있음

이건 아마 np.max(target) - np.min(target) = 0 인 경우 였을 것 같은데, target 안의 모든 값이 같으면 문제가 될 듯


아 그래서 저렇게 수정한거구나 👍👍👍

ktiberius commented 6 months ago
[231]
/Users/jinho/Documents/OMR/read_omr.py:169: RuntimeWarning: invalid value encountered in scalar divide
  return [(x - np.min(target)) / (np.max(target) - np.min(target)) for x in target]

target 에 값이 1개 뿐일 때 저렇게 되네 오호

omr_20240307175935.pdf 에서 이름 초성 가져올 때 발생

ktiberius commented 6 months ago

https://github.com/Choi-Hong-Jun/OMR/blob/d64ec9d15252b81fc3e4c43a9b3b4dc2e5e306ee/read_omr.py#L116-L132

이 부분이 indent가 잘못 처리됨 loop 문 안으로 들어와서 ㄱ ~ ㅎ까지 다 돌지 못하고 return 수행

아래 commit으로 수정됐는데,

https://github.com/Choi-Hong-Jun/OMR/commit/d64ec9d15252b81fc3e4c43a9b3b4dc2e5e306ee#diff-c9a27e4f18581e791b05cd1260f7a7433924bb5bda1fe703088e44444fcea3f3R112-R132

ktiberius commented 6 months ago

19 에서 수정 후 동작 확인