Skip to content

A simple python wrapper for gpupixel using SourceRawDataInput and TargetRawDataOutput.

License

Notifications You must be signed in to change notification settings

quqixun/gpupixel_pywrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPUPixel Python Wrapper

A simple python wrapper for gpupixel using SourceRawDataInput and TargetRawDataOutput.
Code in this repository was only tested on Windows 10.

1. Modify and build gpupixel

1.1 Install CMake and MinGW64

  • 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_DIR where the installation path of your choice.
  • Add a system variable with the name MinGW_HOME, which has the value MINGW64_DIR.
  • Append MINGW64_DIR\bin to the system PATH.

1.2 Clone and modify gpupixel

Clone gpupixel:

git clone --depth 1 --branch v1.2.5 git@github.com:pixpark/gpupixel.git
# or try to use the latest code
# git clone git@github.com:pixpark/gpupixel.git

Clone gpupixel_pywrapper:

git clone git@github.com:quqixun/gpupixel_pywrapper.git

Modify 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.

1.3 Build gpupixel

Build library of gpupixel:

cd gpupixel
cmake -G "MinGW Makefiles" -B build -S src
cmake --build build --config Debug  # or Release

Then, libgpupixel.dll can be found in gpupixel\output\library\windows.

2. C++ Wrapper (Optional)

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 Release

In gpupixel\output\wrapper\windows, run test:

gpupixel_cli.exe demo.png output.png 10 10 10 10 10 10

This step is not necessary for building python wrapper.

3. 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 Release

libgpupixel_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.

About

A simple python wrapper for gpupixel using SourceRawDataInput and TargetRawDataOutput.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published