Compiling lpub3d
Lpub3d is an open source cross platform GUI application to create Lego brick instructions. I noticed that the program created intermediate images in a temp directory that were later composited into the final page. I posited that I could grab these midstream and use them as annotated image data for machine learning. I compiled Lpub3d on Linux but the native renderer did not render edges correctly and after struggling to compile it on Windows, I succeeded ( one time ) and the edges rendered properly and here I document this procedure for a future me in case I might want to compile it again.
During Windows compiling that led to a lot of native rendering runtime errors I discovered Lpub3d uses various 3rd party renderers to generate brick images that it uses to composite a page of instructions. These 3rd party renderers predate Lpub3d and can be called on the command line, negating the need to rewire Lpub3d for this purpose.
The native renderer is based on the Leocad engine and may be faster since it is compiled into the main app. Ldglite is another renderer that is called via the command line that has a different line quality. I propose to use both to generate a variety of training data.
While playing around with Leocad, I can adjust the width and height of the rendered image nad assumed that if I just supplied one, the other value would be auto set to the bounding box of the part. Unfortunately it hardcoded to 1280 x 720. Persuing the render.cpp code reveals some clip to alpha functions so I am guessing that unlike ldglite which DOES have auto bbox, that Lpub3d just takes whatever is spit out by Leocad and does a post pass to crop it.
Compiling Lpub3d requires QT5 along with Visual Studio 2019 community along with some other dependencies. My initial compile with 2.4.6 create a problem free executable, with manually installing all the dependencies. Since the updatee to 2.4.7 I have been unable to get a problem free compile even if I tried to git the --branch 2.4.6. Lpub3d starts up fine but cannot use the native renderer and when switching to LDGLite it renders perfectly.
- New direction: bypass Lpub3d and use Leocad and LDGLite on the command line and use python Pillow to autocrop the renders.
Open an administative cmd
Install Visual Studio 2019 Community
choco install visualstudio2019community --package-parameters "--add Microsoft.VisualStudio.Component.Windows10SDK.17763 --add Microsoft.VisualStudio.Component.VC.ATLMFC --add Microsoft.VisualStudio.Component.VC.CLI.Support --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.140 --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.17763" -y --execution-timeout 9000
Install QT5
choco install aqt -y
aqt install-qt -O C:\Qt\IDE windows desktop 5.15.2 win32_msvc2019
aqt install-qt -O C:\Qt\IDE windows desktop 5.15.2 win64_msvc2019_64
aqt install-qt -O C:\Qt\IDE windows desktop 5.15.2 win32_mingw81
aqt install-qt -O C:\Qt\IDE windows desktop 5.15.2 win64_mingw81
Install 7zip, git, msys2
choco install msys2 --params "/InstallDir:C:\Msys2\Msys64" -y
choco install 7zip git -y
``