Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Library/SpoutSDK.pyd
Binary file not shown.
66 changes: 36 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,70 @@
# Spout for Python
A modified Spout library using Boost::Python to enable Spout texture sharing using Python.
![Spout for Python](https://raw.githubusercontent.com/spiraltechnica/Spout-for-Python/master/Images/neural%20style%20resolume.png)
This library is for use with Python 3.5 64bit.

It was built against Boost 1.65 and Python 3.5.2-amd64 using Visual Studio 2015 on Windows 10 64bit

The Visual Studio solution depends on:
![Spout for Python](https://raw.githubusercontent.com/spiraltechnica/Spout-for-Python/master/Images/neural%20style%20resolume.png)

- Boost being located in C:\Program Files\boost_1_65_0 and
This library is for use with Python 3.7 64bit.

- Python 3.5 64bit being located in %UserProfile%\AppData\Local\Programs\Python\Python35\include
It was built against Boost 1.69 and Python 3.7.2-amd64 using Visual Studio 2017 on Windows 10 64bit

This modified library does not yet fully implement the functionality available in the SpoutSDK.
This modified library does not yet fully implement the functionality available in the SpoutSDK.

## Using the Library
The SpoutSDK.pyd library is located in the [Library/](Library/) folder of this repository. The example files are in the [Examples/](Examples/) folder.
The SpoutSDK.pyd library is located in the [Library/](Library/) folder of this repository. The example files are in the [Examples/](Examples/) folder.

You shouldn't need to compile Boost or have Visual Studio installed to run these examples and integrate the library into your own Python projects

And of course, if you don't have Spout installed, you'll definitely need to get it and install it. It's available at http://spout.zeal.co/
You shouldn't need to compile Boost or have Visual Studio installed to run these examples and integrate the library into your own Python projects, but you'll definitely need to install [Spout](http://spout.zeal.co/).

## Examples


Take a look in the [Examples/](Examples/) folder for a list of python scripts that can interface with the modified SpoutSDK.pyd library.

The simplest example file is ```hello.py```. This merely attempts to import the library, create an instance of a Spout Sender, and call a function that returns text into the console.
The simplest example file is ```hello.py```. This merely attempts to import the library, create an instance of a Spout Sender, and call a function that returns text into the console.

The example scripts ```spout_NST_receiver.py``` and ```spout_NST_sender_receiver.py``` will not run by themselves, because they are designed to work with Tensorflow Fast Style Transfer, located at https://github.com/hwalsuklee/tensorflow-fast-style-transfer

### Running the Examples

A number of the examples will require libraries not in the base Python 3.5 install. That base install is available at https://www.python.org/downloads/release/python-352/
A number of the examples will require libraries not in the base Python 3.7 install. That base install is available at https://www.python.org/ftp/python/3.7.2/python-3.7.2-amd64.exe

You'll need
- numpy-1.13.1+mkl-cp35-cp35m-win_amd64.whl
- opencv_python-3.3.0-cp35-cp35m-win_amd64.whl
- pygame-1.9.3-cp35-cp35m-win_amd64.whl

From the Unofficial Windows Binaries for Python Extension Packages at http://www.lfd.uci.edu/~gohlke/pythonlibs/
- numpy 1.16.2
- opencv-python 4.0.0.21
- pygame 1.9.4
- PyOpenGL 3.1.0

Install them using the pip3 manager that comes with Python 3.5, using the ```pip install <filename>``` command from the command line.
Install them using the pip manager that comes with Python 3.7, using the ```pip install <filename>``` command from the command line.

In addition to the aforementioned packages, you'll need PyOpenGL from the pip default repositories:
- Install using ```pip install PyOpenGL``` command. The version I'm using is PyOpenGL 3.1.0
- It would be also worth installing Pillow with ```pip install Pillow```. I'm using Pillow 4.2.1

## Building Boost
- Download the Boost 1.65 source for windows from http://www.boost.org/users/history/version_1_65_0.html
- Extract to C:\Program Files\boost_1_65_0
Requires the prior installation of [MS Visual Studio 17](https://visualstudio.microsoft.com/de/vs/) Community Edition.

- Download the Boost 1.69 source for windows from https://www.boost.org/users/history/version_1_69_0.html
- Extract to C:\Program Files\boost_1_69_0
- Open an Administrative access Command Prompt (right click on Command Prompt and Run As Administrator)
- cd into C:\Program Files\boost_1_65_0
- cd into C:\Program Files\boost_1_69_0
- Type ```boostrap.bat``` and run the command
- Now run ```.\b2.exe --stagedir=./stage/x64 address-model=64 --build-type=complete --toolset=msvc-14.0 --threading=multi --runtime-link=shared --variant=debug```

This will take some time. Once it's complete run
- ```.\b2.exe --stagedir=./stage/x64 address-model=64 --build-type=complete --toolset=msvc-14.0 --threading=multi --runtime-link=shared --variant=release```
- Now run ```.\b2.exe --stagedir=./stage/x64 address-model=64 --build-type=complete --toolset=msvc-14.1 --threading=multi --runtime-link=shared --variant=debug```

This will take some time creating the debug libraries. Once it's complete run
- ```.\b2.exe --stagedir=./stage/x64 address-model=64 --build-type=complete --toolset=msvc-14.1 --threading=multi --runtime-link=shared --variant=release```

Which most likely will take much less time to create the release libraries. However, it should say it is successfully built at the end and give you locations for linker library include paths and compiler include paths. You only need them if you decided to extract and build boost at a different location.

## Building the DLL rsp. PYD

The Visual Studio solution depends on:

- Boost being located in C:\Program Files\boost_1_69_0 and

- Python 3.7 64bit being located in %UserProfile%\AppData\Local\Programs\Python\Python37\include

Which will also take some time. However, it should say it is successfully built at the end and give you locations for linker library include paths and compiler include paths.
With Boost and Python installed you should now be able to use Visual Studio 2017 and build the ```SpoutSDK.dll``` for 64bit architecture in Debug and Release modes. In order to interface the dll with Python, rename the dll from ```SpoutSDK.dll``` to ```SpoutSDK.pyd```.

## Building the DLL
## Credits

With Boost and Python installed you should now be able to use Visual Studio 2015 and build the ```SpoutSDK.dll``` for 64bit architecture in Debug and Release modes. In order to interface the dll with Python, rename the dll from ```SpoutSDK.dll``` to ```SpoutSDK.pyd```.
- Ryan Walker (http://www.spiraltechnica.com/)
- Martin Froehlich (http://tecartlab.com)
34 changes: 32 additions & 2 deletions SpoutSDK/SpoutSDK/Spout.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
/*

Spout.h

The main Spout include file for the SDK

Copyright (c) 2014-2017, Lynn Jarvis. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


*/
#pragma once

#ifndef __Spout__
#define __Spout__


#include "SpoutSender.h"
#include "SpoutReceiver.h"

// All documentation in the SDK pdf = SpoutSDK.pdf

#endif
#endif
11 changes: 8 additions & 3 deletions SpoutSDK/SpoutSDK/SpoutDirectX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
// 04.09.16 - Add create DX11 staging texture
// 16.01.17 - Add WriteDX9surface
// 23.01.17 - pEventQuery->Release() for writeDX9surface
// 24.04.17 - Added MessageBox error warnings in CreateSharedDX11Texture
// 24.04.17 - Add MessageBox error warnings in CreateSharedDX11Texture
// 11.11.18 - Add GetImmediateContext()
//
// ====================================================================================
/*

Copyright (c) 2014-2017. Lynn Jarvis. All rights reserved.
Copyright (c) 2014-2018. Lynn Jarvis. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -345,6 +346,11 @@ ID3D11Device* spoutDirectX::CreateDX11device()

} // end CreateDX11device

ID3D11DeviceContext* spoutDirectX::GetImmediateContext()
{
return g_pImmediateContext;
}


bool spoutDirectX::CreateSharedDX11Texture(ID3D11Device* pd3dDevice,
unsigned int width,
Expand Down Expand Up @@ -783,7 +789,6 @@ bool spoutDirectX::FindNVIDIA(int &nAdapter)
if(bFound) {
printf("Found NVIDIA adapter %d (%S)\n", i, desc.Description);
nAdapter = i;
// LJ DEBUG
// 0x10DE NVIDIA
// 0x163C intel
// 0x8086 Intel
Expand Down
3 changes: 3 additions & 0 deletions SpoutSDK/SpoutSDK/SpoutDirectX.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class SPOUT_DLLEXP spoutDirectX {

// DX11
ID3D11Device* CreateDX11device(); // Create a DX11 device
ID3D11DeviceContext* GetImmediateContext();
bool CreateSharedDX11Texture(ID3D11Device* pDevice, unsigned int width, unsigned int height, DXGI_FORMAT format, ID3D11Texture2D** pSharedTexture, HANDLE &dxShareHandle);
bool CreateDX11StagingTexture(ID3D11Device* pDevice, unsigned int width, unsigned int height, DXGI_FORMAT format, ID3D11Texture2D** pStagingTexture);
bool OpenDX11shareHandle(ID3D11Device* pDevice, ID3D11Texture2D** ppSharedTexture, HANDLE dxShareHandle);
Expand All @@ -86,6 +87,8 @@ class SPOUT_DLLEXP spoutDirectX {
// For debugging only - to toggle texture access locks disable/enable
bool bUseAccessLocks;



protected:

IDXGIAdapter* GetAdapterPointer(int index); // Get adapter pointer for DirectX 11
Expand Down
Loading