Zarbuz / FileToVox

Tool for convert files into Magicavoxel file
MIT License
445 stars 46 forks source link

PLY to VOX Color Palette issue? libgdiplus installled but no luck #26

Closed enzyme69 closed 2 years ago

enzyme69 commented 3 years ago

I am getting result where the voxel color seems to have the palette, but they are not transferring color to each voxel. Very strange.

Screen Shot 2021-02-01 at 12 08 23 pm

Original point cloud: IMG_F6175288794C-1

enzyme69 commented 3 years ago

I wonder if you can try and convert to vox the original PLY below: rainbow 2.ply.zip

enzyme69 commented 3 years ago
192-168-1-110:FileToVox-v1 jimmygunawan$ dotnet FileToVox.dll -i /Users/jimmygunawan/Downloads/rainbow.ply -scale 70 -o rainbow
[INFO] Specified input path: /Users/jimmygunawan/Downloads/rainbow.ply
[INFO] Specified output path: rainbow
[INFO] Specified increase size: 70
[INFO] Specified output path: /Applications/FileToVox-v1/rainbow
[LOG] Start reading PLY data...
[LOG] Done.        
[LOG] Started to voxelize data...
[LOG] Done.        
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
 ---> System.DllNotFoundException: Unable to load DLL 'libgdiplus': The specified module could not be found.
   at System.Runtime.InteropServices.FunctionWrapper`1.get_Delegate()
   at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
   at System.Drawing.SafeNativeMethods.Gdip..cctor()
   --- End of inner exception stack trace ---
   at System.Drawing.SafeNativeMethods.Gdip.GdipCreateBitmapFromScan0(Int32 width, Int32 height, Int32 stride, Int32 format, HandleRef scan0, IntPtr& bitmap)
   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
   at FileToVox.Extensions.Quantization.CreateBitmapFromColors(List`1 blocks) in E:\Documents\FileToVox\SchematicToVoxCore\Extensions\Quantization.cs:line 50
   at FileToVox.Extensions.Quantization.ApplyQuantization(List`1 blocks, Int32 colorLimit) in E:\Documents\FileToVox\SchematicToVoxCore\Extensions\Quantization.cs:line 15
[INFO] Vox Width: 466
[INFO] Vox Length: 478
[INFO] Vox Height: 140
[LOG] Started to compute the first block for each region
[LOG] Done.        
enzyme69 commented 3 years ago

Warning: mono-libgdiplus 6.0.5_1 is already installed and up-to-date.

I have tried installing libgdiplus but somewhat still no luck with color and still getting error: Unable to load DLL 'libgdiplus': The specified module could not be found

==> Downloading https://homebrew.bintray.com/bottles/mono-libgdiplus-6.0.5_1.big_sur.bottle.tar.gz
Already downloaded: /Users/jimmygunawan/Library/Caches/Homebrew/downloads/f2abbfc0e8e424f9eda3263a7397fbf7761ac9a11c802165efaadee045f0bbfe--mono-libgdiplus-6.0.5_1.big_sur.bottle.tar.gz
==> Pouring mono-libgdiplus-6.0.5_1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/mono-libgdiplus/6.0.5_1: 13 files, 1MB
Zarbuz commented 3 years ago

image

The conversion works well if you have indeed the libgdiplus library installed.

enzyme69 commented 3 years ago

@Zarbuz Yes, I don't know what I did wrong because I brew that library and it's inside Cellar. Do I need to manually assign path or something?

Zarbuz commented 3 years ago

The official way to install libgdiplus is to use this command : brew install mono-libgdiplus for MacOS.

Did you tried to relaunch your command prompt after the installation of libgdiplus ?

enzyme69 commented 3 years ago

Yes I tried relaunching terminal multiple times.

Screen Shot 2021-02-01 at 7 42 44 pm Screen Shot 2021-02-01 at 7 44 06 pm Screen Shot 2021-02-01 at 7 30 48 pm
enzyme69 commented 3 years ago

I found this: https://gist.github.com/mtolly/384dbe51f4a78d6d2818

The mention of that nuget "runtime.osx.10.10-x64.CoreCompat.System.Drawing" etc, I also tried that but still no luck. I might be close and have to keep digging...

Screen Shot 2021-02-01 at 7 47 56 pm
enzyme69 commented 3 years ago

I ended up creating new account on my MacOS, and it seems to work now. Same computer, different account. Maybe this one is pointing at the correct library. Weird... Thanks all!

Last login: Mon Feb  1 21:10:36 on console
Restored session: Mon  1 Feb 2021 21:02:56 AEDT
blendersushi@192-168-1-110 FileToVox-v1 % dotnet FileToVox.dll -i /Users/blendersushi/Downloads/piggu.ply -scale 70 -o piggu

[INFO] Specified input path: /Users/blendersushi/Downloads/piggu.ply
[INFO] Specified output path: piggu
[INFO] Specified increase size: 70
[INFO] Specified output path: /Users/blendersushi/Downloads/FileToVox-v1/piggu
[LOG] Start reading PLY data...
[LOG] Done.        
[LOG] Started to voxelize data...
[LOG] Done.        
[INFO] Vox Width: 593
[INFO] Vox Length: 753
[INFO] Vox Height: 266
[LOG] Started to compute the first block for each region
[LOG] Done.        
[INFO] Total blocks: 243297
[LOG] Started to write chunks ...
[########--]  85% \[LOG] Done.
[LOG] Check total blocks after conversion: 243297
[LOG] Done.
blendersushi@192-168-1-110 FileToVox-v1 % 
enzyme69 commented 3 years ago

--- NEED TO REOPEN

I am now using iMac M1 and having the same issue quite annoying. I can't get the mono-libgdiplus running properly on this new account.

How to actually add reference? This is so confusing for non coder like me :(

https://solrevdev.com/2020/12/04/dllnotfoundexception-unable-to-load-shared-library-libgdiplus-or-one-of-its-dependencies.html

enzyme69 commented 3 years ago

Maybe somewhere along this line: dotnet add package runtime.osx.10.10-x64.CoreCompat.System.Drawing

enzyme69 commented 3 years ago

https://github.com/mono/libgdiplus/issues/696

enzyme69 commented 3 years ago

If it's a matter of linking, I also have no idea how to search and link it: https://github.com/dotnet/runtime/issues/34646