RealSenseID icon indicating copy to clipboard operation
RealSenseID copied to clipboard

Building python wrapper

Open openlayers-droid opened this issue 4 years ago • 11 comments

hi, so I followed instructions on building python wrapper, but I couldn't find either rsid_py.pyd nor rsid.ddl after the cmake process. Kindly assist.

Many thanks

openlayers-droid avatar Aug 04 '21 15:08 openlayers-droid

check in build folder inside lib

ryan185 avatar Aug 05 '21 00:08 ryan185

Many thanks @ryan185 . There were few things that had to be taken care of:

  1. not familiar how cmake works, i thought it would just create the python pyd file automatically. instead, i had to run the solution file inside Wrappere->python and build to generate the needed files.
  2. i create an environment with Python 3.8. The python code samples produced an error. Upgraded to python39 and samples work as intended.
  3. to be able to import rsid_py, other extra steps are needed such as creating init.py / adding the folder which hosts the pyd to PYTHONPATH.

i wasted a day figuring this out. So hope this helps someone.

openlayers-droid avatar Aug 05 '21 06:08 openlayers-droid

Python files are working in windows the sample file?

ryan185 avatar Aug 06 '21 02:08 ryan185

@ryan185 yes they are working after the conducting the steps above.

openlayers-droid avatar Aug 06 '21 06:08 openlayers-droid

File "C:\RealSenseID-master\samples\python\viewer.py", line 237, in main() File "C:\RealSenseID-master\samples\python\viewer.py", line 233, in main input_loop() File "C:\RealSenseID-master\samples\python\viewer.py", line 126, in input_loop cmd_exec.get(chr(keycode), lambda: None)() File "C:\RealSenseID-master\samples\python\viewer.py", line 89, in enroll_example with rsid_py.FaceAuthenticator(PORT) as f: RuntimeError: Error

ryan185 avatar Aug 06 '21 07:08 ryan185

This happened to me at first as well. it turns out to be Python version. i was using python 3.9. downgraded to python 3.8 and it worked.

openlayers-droid avatar Aug 06 '21 07:08 openlayers-droid

run the solution file inside Wrappere->python and build to generate the needed files.

@openlayers-droid I am having the same problem with rsid_py.pyd and rsid.ddl. They are not being generated after cmake. Could you elaborate on the "solution file" you mentioned?

I have run "cmake -DRSID_PY=ON -DRSID_PREVIEW=ON .. " inside ProjectDir/RealSenseID/wrappers/python, but then it complains that "RealSenseID/wrappers/3rdparty/pybind11/CMakeLists.txt does not exist."

sbekbulaeva avatar Aug 27 '21 17:08 sbekbulaeva

@sbekbulaeva The steps like this.

  1. mkdir build in the root of this project. (<RealSenseID>/build)
  2. run "cmake -DRSID_PY=ON -DRSID_PREVIEW=ON .. " in the build folder
  3. run make

RealSenseSupport avatar Oct 18 '21 09:10 RealSenseSupport

Has anyone been successful building the python wrappers in ubuntu/linux? I created an issue here https://github.com/IntelRealSense/RealSenseID/issues/147

rukshanfonseka avatar Jul 08 '22 08:07 rukshanfonseka

Many thanks @ryan185 . There were few things that had to be taken care of:

  1. not familiar how cmake works, i thought it would just create the python pyd file automatically. instead, i had to run the solution file inside Wrappere->python and build to generate the needed files.
  2. i create an environment with Python 3.8. The python code samples produced an error. Upgraded to python39 and samples work as intended.
  3. to be able to import rsid_py, other extra steps are needed such as creating init.py / adding the folder which hosts the pyd to PYTHONPATH.

i wasted a day figuring this out. So hope this helps someone.

Can you explain how you managed to overcome issue 3)? I am facing the same problem.

rukshanfonseka avatar Jul 11 '22 04:07 rukshanfonseka

@RealSenseSupport

  1. mkdir build in the root of this project. (/build)
  2. run "cmake -DRSID_PY=ON -DRSID_PREVIEW=ON .. " in the build folder
  3. run make

Still can not compile wrapper files for python. OS Windows 10 x64

1 . mkdir build in the root of this project. (/build) root of the project consists of these dirs (my path to project is "f:\Cmake_test\test3"):

f:\Cmake_test\test3\3rdparty\
f:\Cmake_test\test3\cmake\
f:\Cmake_test\test3\docs\
f:\Cmake_test\test3\include\
f:\Cmake_test\test3\LicenseNotices\
f:\Cmake_test\test3\samples\
f:\Cmake_test\test3\scripts\
f:\Cmake_test\test3\src\
f:\Cmake_test\test3\tools\
f:\Cmake_test\test3\wrappers\

so i just need to make dir f:\Cmake_test\test3\build\ right?

2. run "cmake -DRSID_PY=ON -DRSID_PREVIEW=ON .. " in the build folder I need to run this command from inside folder f:\Cmake_test\test3\build\ ?

And in it means that it will generate files needed to MAKE Python wrapper in this folder according to "CMakeLists.txt" file located in project root folder f:\Cmake_test\test3\

But i get this error:

CMake Error at tools/rsid-viewer/CMakeLists.txt:4 (project):
  No CMAKE_CSharp_COMPILER could be found.



-- Configuring incomplete, errors occurred!
See also "F:/Cmake_test/test3/build/CMakeFiles/CMakeOutput.log".
See also "F:/Cmake_test/test3/build/CMakeFiles/CMakeError.log".

Ok i dont really care about CSharp BUT on to the step 3 of your advice

3. run make Since i am on Windows i use MSBuild (17.2.1.25201)

Runing it in f:\Cmake_test\test3\build\ returns this error: MSBUILD : error MSB1003 - meaning that this folder doesnt have project files to build

And indeed it doesnt have anything like "sln" or "vcxproj" files.

Such files are located in f:\Cmake_test\test3\build\CMakeFiles\3.24.0-rc3\ and its subfolders but running MSBuild there doesnt give me rsid.dll and rsid_py*.pyd files.

MSBuild works fine. It can be seen in CMakeOutput.log - Run Build Command(s):C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe cmTC_c79d6.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:m && Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework (for example)

So the main question - what am i doing wrong?

VolandSZ avatar Jul 16 '22 22:07 VolandSZ