Skip to main content

Sprites Detection

A sprite is a small raster graphic (a bitmap) that represents an object such as a character, a vehicle, a projectile, etc.

Sprite Sheet

It is not uncommon for games to have tens to hundreds of sprites. Loading each of these as an individual image would consume a lot of memory and processing power. To help manage sprites and avoid using so many images, many games use sprite sheets (also known as image sprites).

A sprite sheet consists of multiple sprites in one image. In other words, sprite sheets pack multiple sprites into a single picture. Using sprite sheet, video game developers create sprite sheet animation representing one or several animation sequences while only loading a single file:

Metal Slug Sprites

Sprite Bounding Box

A frame (bounding box) can be used to delimit the sprite in the sprite sheet. This bounding box is defined with two 2D points top_left and the bottom_right, which their respective coordinates x and y are relative to the top-left corner of the sprite sheet's image.

For example:

Shape Bounding Boxes

Sprite Mask

The mask of a sprite defines the 2D shape of the sprite. For example, the sprite sheet metal_slug_sprite_standing_stance.png contains the 3 following sprites:

Metal Slug Standing Stance

The masks of these sprites are respectively:

Aim of the project

  • Detect sprites packed in an image (sheet) and draw their masks and bounding boxes into a new image with the same size of the original image.
  • Present a 2D map of all the the sprites with their labels.

Waypoint Delivered:

  • Waypoint 1: Find the Most Common Color in an Image
  • Waypoint 2: Write a Class Sprite
  • Waypoint 3: Find Sprites in an Image
  • Waypoint 4: Draw Sprite Label Bounding Boxes
  • Waypoint 5: Write a Class SpriteSheet

Usage Information

Prerequisites

  • Python 3.7 is required.
  • numpy (python support library)
  • PIL.Image (python support library)

Usage

  • Use git to clone the link to your local directory.
  • Change the your current working directory to where you git the project.
  • Open terminal and type pipenv install -e Pipfile to install virtual environment.
  • For example:
>>> from spriteutil import *
>>> sprite_sheet = SpriteSheet('Barbarian.gif')
>>> sprites, labels = sprite_sheet.find_sprites()
>>> len(sprites)
39
>>> # Create the mask image with bounding boxes.
>>> image = sprite_sheet.create_sprite_labels_image()
>>> image.save('barbarian_bounding_boxes.png')

Contact Information

  • If you have any problems using this library, please use the contact below.
    Email: cuong.nguyen@f4.intek.edu.vn

Metadata

Release files for spriteutil-intek-2020-nqcuong96 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spriteutil-intek-2020-nqcuong96 1.0.0
File Size Uploaded Provenance Actions
spriteutil-intek-2020-nqcuong96-1.0.0.tar.gz 6.8 kB Without provenance Details for spriteutil-intek-2020-nqcuong96-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for spriteutil-intek-2020-nqcuong96 1.0.0
File Interpreter ABI Platform Actions
spriteutil_intek_2020_nqcuong96-1.0.0-py3-none-any.whl Python 3 none any Details for spriteutil_intek_2020_nqcuong96-1.0.0-py3-none-any.whl

Total release size: 14.6 kB

Release files / spriteutil-intek-2020-nqcuong96-1.0.0.tar.gz

Download URL spriteutil-intek-2020-nqcuong96-1.0.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c51e1b63f85384985bad7c61dabef655bac31a65aa5ebe7dc2c068aff8744efa
BLAKE2b-256 checksum
How to use checksums
4b3c674f44d8a2e4f2a77d2dc47fef0c214c880f10adb647abd52a0e9f97cb2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

Release files / spriteutil_intek_2020_nqcuong96-1.0.0-py3-none-any.whl

Download URL spriteutil_intek_2020_nqcuong96-1.0.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00c342ea7573b3f293dfbc8b110854f6af49b2d0579a11666e209cd99b7295d2
BLAKE2b-256 checksum
How to use checksums
6f87b9b56addbd391c4a91357f9755bab5065951e25783eb6111a454e1ddfc58
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.4

Security for spriteutil-intek-2020-nqcuong96 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page