A simple python wrapper for gpupixel using SourceRawDataInput and TargetRawDataOutput.
Code in this repository was only tested on Windows 10.
- Download and install cmake.
- Download MinGW64 from here. Select MinGW-W64 GCC-8.1.0 x86_64-posix-seh to download.
- Unzip MinGW64 to
MINGW64_DIRwhere the installation path of your choice. - Add a system variable with the name
MinGW_HOME, which has the valueMINGW64_DIR. - Append
MINGW64_DIR\binto the systemPATH.
Clone gpupixel:
git clone --depth 1 --branch v1.2.5 [email protected]:pixpark/gpupixel.git
# or try to use the latest code
# git clone [email protected]:pixpark/gpupixel.gitClone gpupixel_pywrapper:
git clone [email protected]:quqixun/gpupixel_pywrapper.gitModify gpupixel\src\target\target_raw_data_output.cc according to issue.
Or you can copy target_raw_data_output.cc to gpupixel\src\target to replace the older one.
Copy stb_image_write.h to gpupixel\src\third_party\stb for writing image in test.
Find more infomation about stb.
Build library of gpupixel:
cd gpupixel
cmake -G "MinGW Makefiles" -B build -S src
cmake --build build --config Debug # or ReleaseThen, libgpupixel.dll can be found in gpupixel\output\library\windows.
GPUPixelWrapper is a C++ encapsulation for gpupixel using SourceRawDataInput and TargetRawDataOutput.
cli.cc demonstrates its usage.
Copy wrapper directory to gpupixel and build it:
cd gpupixel
cmake -G "MinGW Makefiles" -B wrapper/build -S wrapper
cmake --build wrapper/build --config Debug # or ReleaseIn gpupixel\output\wrapper\windows, run test:
gpupixel_cli.exe demo.png output.png 10 10 10 10 10 10This step is not necessary for building python wrapper.
Finally, we just wrap the GPUPixelWrapper in gpupixel_pywrapper.cc and it's ready for python to call.
Copy pywrapper directory to gpupixel and build it:
cd gpupixel
cmake -G "MinGW Makefiles" -B pywrapper/build -S pywrapper
cmake --build pywrapper/build --config Debug # or Releaselibgpupixel_pywrapper.dll can be found in gpupixel\output\pywrapper\windows.
Copy test_pywrapper.py to gpupixel\output\pywrapper\windows, and run python test_pywrapper.py to check result.
I'm not a C++ developer, the code in this repository was developed with the assistance of ChatGPT.
This may not be the best solution, but it is good enough for my project at the moment.
I am always looking forward to a better one.