abhiTronix / vidgear

A High-performance cross-platform Video Processing Python framework powerpacked with unique trailblazing features :fire:
https://abhitronix.github.io/vidgear
Apache License 2.0
3.39k stars 255 forks source link

[Bug]: `simplejpeg` Incompatibility with `numpy` Version `>= 2.0.0` #408

Closed abhiTronix closed 5 months ago

abhiTronix commented 5 months ago

Description

The backend simplejpeg library used in our WebGear and NetGear APIs primarily for frame compression, is not compatible with the newer versions of numpy (>= 2.0.0). The recent changes in numpy have introduced modifications that cause issues with the simplejpeg Turbo C API.

Issue Checklist

Expected behaviour

import simplejpeg should work out of the box

Actual behaviour

Currently, importing simplejpeg throws the following error:

>>> import simplejpeg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Abhishek Thakur\AppData\Roaming\Python\Python310\site-packages\simplejpeg\__init__.py", line 1, in <module>
    from ._jpeg import encode_jpeg
  File "simplejpeg\\_jpeg.pyx", line 1, in init simplejpeg._jpeg
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Steps to reproduce

Terminal log output

>>> import simplejpeg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Abhishek Thakur\AppData\Roaming\Python\Python310\site-packages\simplejpeg\__init__.py", line 1, in <module>
    from ._jpeg import encode_jpeg
  File "simplejpeg\\_jpeg.pyx", line 1, in init simplejpeg._jpeg
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Python Code(Optional)

No response

VidGear Version

0.3.3

Python version

any

OpenCV version

latest

Operating System version

any

Any other Relevant Information?

https://github.com/jfolz/simplejpeg/issues/2

abhiTronix commented 5 months ago

Workaround

As a workaround, downgrading numpy to a version <2.0.0 works for now. If you want to use simplejpeg, you can downgrade numpy before installing vidgear:

# Downgrade numpy to <2.0.0
pip install "numpy<2.0.0"

# Install vidgear core
pip install vidgear[core]

# Or install vidgear asyncio
pip install vidgear[asyncio]
abhiTronix commented 5 months ago

This issue is fixed with simplejpeg version 1.74.