Skip to main content

hpsdecode

Build Status PyPI Version Python Version License

A Python library for decoding HPS (HIMSA Packed Scan) and DCM files used by dental and audiological scanning software such as 3Shape and ShapeDesigner.

HPS is a compressed 3D mesh format commonly used in dental scanning applications and other HIMSA-compliant devices.

Features

  • Read mesh geometry (vertices and faces) from HPS files.
  • Supports CA, CC, and CE schemas, including encrypted files.
  • Extract mesh colors, texture coordinates (UVs) and texture images.
  • Extract splines and curves in the scan data.
  • Export the mesh to OBJ, PLY and STL.
  • Command-line tool for exporting meshes.

Getting Started

Installation

pip install hpsdecode

Basic Usage

from hpsdecode import load_hps

# Load from file path
packed, mesh = load_hps("scan.dcm")

# Access mesh data
print(f"Vertices: {mesh.num_vertices}")
print(f"Faces: {mesh.num_faces}")
print(f"Schema: {packed.schema}")

# Vertex positions as (N, 3) float32 array
vertices = mesh.vertices

# Face indices as (M, 3) int32 array  
faces = mesh.faces

Compression Schemas

Schema Status Description
CA ✅ Supported Identical to CC; provided for backward compatibility.
CB ❌ Not Planned Lossy compression with optional color and texture data. No example data available.
CC ✅ Supported Lossless compression with uncompressed vertices and compressed faces.
CE ✅ Supported Encrypted version of CC. Requires an encryption key.

Encrypted Files (CE Schema)

Some HPS files use the CE schema, which encrypts the mesh data. To decode these files, you must provide the encryption key.

[!NOTE] This library does not provide encryption keys, nor will it provide instructions on how to obtain them.

Providing the Encryption Key

Option 1: Environment Variable (Recommended)

Set the HPS_ENCRYPTION_KEY environment variable before loading files:

export HPS_ENCRYPTION_KEY="28,141,16,74,219,32,11,126,55,178,97,3,41,82,213,222"
from hpsdecode import load_hps

# Automatically uses the key from the environment variable
packed, mesh = load_hps("encrypted.hps")

Option 2: Direct Key

Provide the key directly as a bytes object:

from hpsdecode import load_hps

key = bytes([28, 141, 16, 74, 219, 32, 11, 126, 55, 178, 97, 3, 41, 82, 213, 222])

packed, mesh = load_hps("encrypted.hps", encryption_key=key)

Option 3: Custom Key Provider

Implement your own key provider for advanced use cases (e.g., loading from a configuration file):

from hpsdecode import load_hps
from hpsdecode.encryption import EncryptionKeyProvider

class MyKeyProvider(EncryptionKeyProvider):
    def get_key(self, properties):
        return load_key_from_config()


key_provider = MyKeyProvider()
packed, mesh = load_hps("encrypted.hps", encryption_key=key_provider)

File Format Overview

HPS files are XML documents containing base64-encoded binary mesh data:

<HPS version="1.1">
    <Packed_geometry>
        <Schema>CA</Schema>
        <Binary_data>
            <CA version="1.0">
                <Vertices base64_encoded_bytes="..." vertex_count="...">
                    <!-- Base64-encoded float32 vertex positions -->
                </Vertices>
                <Facets base64_encoded_bytes="..." facet_count="...">
                    <!-- Base64-encoded face commands -->
                </Facets>
            </CA>
        </Binary_data>
    </Packed_geometry>
</HPS>

Command-Line Interface (CLI)

After installing, you can use the hpsdecode command to export meshes directly from HPS files.

Exporting Meshes

hpsdecode export input.hps output.obj

You can specify options such as export format (auto-detected by file extension), ASCII or binary mode, and whether to include/exclude colors or textures:

hpsdecode export input.hps output.ply --ascii --no-colors --no-textures

Encrypted HPS files (CE schema) require an encryption key.
You can supply it using --key or the HPS_ENCRYPTION_KEY environment variable:

hpsdecode export encrypted.hps output.obj --key "28,141,16,74,..."

Material Options

For OBJ export, you can provide material properties:

hpsdecode export input.hps output.obj \
  --ambient 0.5 0.5 0.5 --diffuse 0.8 0.8 0.8 \
  --specular 1.0 1.0 1.0 --shininess 20 --dissolve 1.0

Run hpsdecode export --help for a full list of CLI options.

Format Support

Format Vertices & Faces Vertex Colors Textures Binary/ASCII
OBJ ✅ ✅* ✅ ASCII
PLY ✅ ✅ ✅** ASCII/Binary
STL ✅ ❌ ❌ ASCII/Binary

* OBJ vertex colors use a non-standard extension; not all software supports this.
** PLY textures are baked into vertex colors. This may result in loss of quality.

Example Scripts

  • Inspect an HPS file:
    Print metadata, stats, and mesh extents to the console:

    python examples/inspect_hps.py path/to/file.hps
    
  • View HPS file in 3D:
    Visualize the mesh in an interactive viewer (requires trimesh):

    python examples/view_hps.py path/to/file.hps
    

    Run pip install trimesh[recommend] for viewing support.

Contributing

Contributions, bug reports, and feature requests are welcome! Please open an issue or pull request if you would like to assist.

If you'd like to support development, consider donating to my Ko-fi page. Every contribution is highly appreciated!

ko-fi

License

This package is licensed under the MIT License. See the LICENSE file for more information.

Metadata

Release files for hpsdecode 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 hpsdecode 1.0.0
File Size Uploaded
hpsdecode-1.0.0.tar.gz 29.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hpsdecode 1.0.0
File Interpreter ABI Platform
hpsdecode-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 68.9 kB

Release files / hpsdecode-1.0.0.tar.gz

Download URL hpsdecode-1.0.0.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cfef4783ea9e8544c2e300a32442b87a252002a85eebd0225215a2a7cbb9af0b
BLAKE2b-256 checksum
How to use checksums
6a534fed2306267c21d7b4d7ab3e7bccfe7ab520903b81480e8490208717c535
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL hpsdecode-1.0.0-py3-none-any.whl
Size 39.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81704fc916143fa1c9e5a875badeea397de4cc3abde6b336f6cfdae3e7f3b733
BLAKE2b-256 checksum
How to use checksums
3fd948663fd921ac61877a1c7f624c86e5b5d7d5d29af4708125567004ffa8c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

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