Skip to main content

Concatenates a list of pictures (numpy arrays) without allocating new memory

pip install fastimgconcat

Tested against Windows 10 / Python 3.10 / Anaconda

from fastimgconcat import temparrays,fastconcat_horizontal,fastconcat_vertical
import numpy as np
import random
import cv2

# This code demonstrates the usage of the fastconcat_vertical()
# function to concatenate pictures (numpy arrays)
# vertically in a
# faster and more efficient way. 
# The fastconcat_vertical() function takes a list of numpy arrays and concatenates
# them vertically without allocating new memory. It is recommended to use this 
# function when you are #concatenating several pictures multiple times, and 
# the shape of the output array never (or rarely) # changes, e.g. streaming
# screenshots of 2 monitors.

# Initialize the height, width and RGB values for the numpy arrays.
height = 200
width = 500
rgbValues0 = np.zeros((height, width, 3), dtype=np.uint8)
rgbValues0[:] = [255, 0, 0]
rgbValues1 = np.zeros((height, width, 3), dtype=np.uint8)
rgbValues1[:] = [0, 0, 255]

# In the for loop, the fastconcat_vertical() 
# function is used to concatenate the numpy arrays vertically.
# If you want to concatenate them horizontally, 
# use fastconcat_horizontal() instead.

checkarraysize = True
for r in range(1000):
    fastconcat_vertical(
        [
            random.choice([rgbValues0, rgbValues1]),
            random.choice([rgbValues0, rgbValues1]),
        ],
        checkarraysize=checkarraysize,
    )
    checkarraysize = False  # If you check the array size each time, it is about 10% slower.

    # The values in temparrays.vertical / temparrays.horizontal 
    # will be changed the next iteration. Therefore,
    # it is recommended to process the output data right
    # after each iteration. If you still need the arrays,
    # copy them (e.g. temparrays.horizontal.copy()), but keep in mind that copying is expensive.

    # This code displays the concatenated image in the cv2 window "test".
    # If the 'q' key is pressed, the program breaks out of the loop and closes the window.
    cv2.imshow("test", temparrays.vertical)
    if cv2.waitKey(1) & 0xFF == ord("q"):
        break
cv2.destroyAllWindows()

Metadata

Release files for fastimgconcat 0.10

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

Source distribution (sdist)

Source distribution for fastimgconcat 0.10
File Size Uploaded Provenance Actions
fastimgconcat-0.10.tar.gz 21.5 kB Without provenance Details for fastimgconcat-0.10.tar.gz

Built distribution (wheel)

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

Total release size: 43.3 kB

Release files / fastimgconcat-0.10.tar.gz

Download URL fastimgconcat-0.10.tar.gz
Size 21.5 kB
Tags Source
SHA-256 checksum
How to use checksums
dfba06a8313d97f0f433da5a4d8d927de7bba2cbb187d717f864b6d05a572d12
BLAKE2b-256 checksum
How to use checksums
e37ea7a4b730426a404a1dba97921805438c4d00fc7957b90f259b3a9a7ead8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / fastimgconcat-0.10-py3-none-any.whl

Download URL fastimgconcat-0.10-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
481b0d4c2b02a922e4ba98965333b226b76e301fdce6c08e70fb06d5a2c34cd3
BLAKE2b-256 checksum
How to use checksums
5f792393248de40f9ee753602f9f80a49405af74a6fd23c4d0680375d09e2f96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for fastimgconcat 0.10

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

0.10 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