Skip to content

Prevent test_cnn.py from crashing w/invalid Tensor label#3

Merged
taras-luxonis merged 1 commit intoluxonis:masterfrom
itsderek23:entry-index-out-of-range
Jan 14, 2020
Merged

Prevent test_cnn.py from crashing w/invalid Tensor label#3
taras-luxonis merged 1 commit intoluxonis:masterfrom
itsderek23:entry-index-out-of-range

Conversation

@itsderek23
Copy link
Copy Markdown

When an object is detected and then leaves the image, the Tensor label returned is typically far outside the list of label indexes (ex: 7552.0). This causes the test_cnn.py to crash.

This checks to ensure the index is within the available labels before applying the label text.

The exception:

Traceback (most recent call last):
  File "test_cnn.py", line 85, in <module>
    cv2.putText(frame, labels[int(e[0]['label'])], pt_t1, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
IndexError: list index out of range

When an object is detected and then leaves the image, the Tensor label
returned is typically far outside the list of label indexes (ex: 7552.0). This
causes the `test_cnn.py` to crash.

This checks to ensure the index is within the available labels before
applying the label text.

The exception:

```
Traceback (most recent call last):
  File "test_cnn.py", line 85, in <module>
    cv2.putText(frame, labels[int(e[0]['label'])], pt_t1, cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
IndexError: list index out of range
```
@Luxonis-Brandon
Copy link
Copy Markdown

Thanks man! I just tried to tag Yurii but his handle isn’t auto-populating on my phone for some reason. Will ping him in slack.

@taras-luxonis taras-luxonis merged commit 3e12c5d into luxonis:master Jan 14, 2020
SzabolcsGergely pushed a commit that referenced this pull request Oct 30, 2020
Prevent test_cnn.py from crashing w/invalid Tensor label
VanDavv added a commit that referenced this pull request Mar 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants