-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Developing a better compression system for the .fset files #34
Comments
@nicolocarpignoli @Carnaux @ThorstenBux i think we could try to compress the files with https://github.com/kripken/lzma.js (it use LZMA compression algorithm) maybe packaged all together and then de-compressed inside jsartoolkit5? Do you think that it worth the try? |
@kalwalt great idea. I was thinking about something like that but haven't started yet to look into possible options. Having that includes into jsartoolkit makes total sense to me. |
So do you think that it could be a good idea? i know that artoolkit5 has zip.c inside ARUtil but i think that the LZMA has a better compression. I will start with this library instead. I will see what i can do! |
Yes good idea for sure. |
ok! 😄
So doesn't it needed to decompress them? or are you saying that can be an issue? |
Saying the browser can potentially decompress them automatically which is a great feature and could save you some work. |
i understood now, thank you! |
Hi there, how are you.
And would have in one file which potentially could be zipped. |
@Carnaux what do you think? |
I think that we can do it, or at least we can try. |
We can do it :). The base64 would work I'm already implementing it. |
Are you testing on the NFT-Marker-Creator? or directly on jsartoolkit5? |
adding the implementation to jsartoolkit5. Once I have that working I change the Marker-Creator to create the JSON file. |
I create the JSON manually for now. |
Ok this sounds good! |
Had a longer experimentation with my idea yesterday. Whereas it works and would allow the files to be contains in one file it does increase the file size by 33% due to the base64 encoding. I think that is not the intention what we are aiming for. For arStudio I would like to have the files within one file but increasing the size by 1/3 isn't suitable either. |
Definetely has no sense, but nice idea, yes we have to think for another solution... |
I think I can make it work using ZLIB(minizip) in C to compress files from memory and save a zip file and then use the same lib to decompress it, I was trying it earlier this week, but I had to do other things. It is in my to-do list, I will keep you guys updated! |
Thank you @Carnaux. One thing to keep in mind though is that on the client (I'm thinking mobile device) the power to decompress might be limited and it needs to be possible to compile it with EM. One other idea is. If we could merge the three files into one with delimiters that are parsed on C side then the server can served a zipped version and the browser would do the unzipping for us automatically. However, I don't know the overhead of parsing of such a combined binary file. |
I will make some benchmarks of performance in PCs and Mobiles. The testing was already with emscripten, but was having some linking issues. When i was researching i found something about compressing the binary with RLE and then storing it as base32, maybe it works for the 3 in 1 idea. |
Hey guys, good news, I got the compression to work, in C and with emscripten. Soon I will create a new repo for you to test it. But the preliminary results show a reduction of about 27%(testing with the pinball image) from 1246KB to 1042Kb. It works this way: I wrote two codes(separate files), one to compress and one to decompress. The compression code: 1 - I read the marker files and convert the raw buffer to a Hex string
2 - Create an object with the contents and stringfy it
I'm using hex strings instead of the buffer, because, on the stringfy, the UTF-8 encoding may compromise part of the data. 3 - Just send it to the C function that compresses and creates a .bin file that we will use as marker file( We can change the extension to whatever name we want, like .arMarker, let's choose a name for it) Then the decompression code: 1- Reads the .binMarker file and writes a temp bin file to Module memory. 2- After reading the file and decompressing it we have the content string:
Now I'm writing the code to parse it and get each hex string and then load into artoolkit. I'm just worried about memory allocation, it works all fine, but it may cause problems in the future when merging with artoolkit or something like it. |
By the way, I'm testing with Node for now, and it all happens within ms, for now, its really fast |
Awesome, work. Love it. Me and @kalwalt we’re thinking of moving jsartoolkit related stuff to a dedicated organisation on GitHub I think your tools would be awesome to live there too. What do you think?
Regarding the name suffix. How about .nft? Or .zft for compressed nft😊.
I’m also setting up a public web service to run the nft creation on which is very fast. Created nfts will be stored on a cloud storage and can be downloaded from there to keep it anyc and integrate it with webarstudio. Basically reusing all of your code and rearrange it a bit to allow for aws lambda deployment. 😊
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Daniel Fernandes Gonçalves de Oliveira <[email protected]>
Sent: Thursday, April 23, 2020 12:45:33 PM
To: kalwalt/jsartoolkit5 <[email protected]>
Cc: Thorsten Bux <[email protected]>; Mention <[email protected]>
Subject: Re: [kalwalt/jsartoolkit5] Developing a better compression system for the .fset files (#34)
By the way, I'm testing with Node for now, and it all happens within ms, for now, its really fast
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkalwalt%2Fjsartoolkit5%2Fissues%2F34%23issuecomment-618112210&data=02%7C01%7C%7Cee209f2002644658a11908d7e71fa212%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637231995349652552&sdata=KxMSvhhMUKmMbJztn7YRH3PRRJQxpDMpRAEYl3psLpE%3D&reserved=0>, or unsubscribe<https://eur05.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAD765PHNSQJH222KBBXLOI3RN6FS3ANCNFSM4KLRXNRA&data=02%7C01%7C%7Cee209f2002644658a11908d7e71fa212%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637231995349662546&sdata=j8Cdwe2Eda19rCcxmGb0QnaV8ROzni%2FnDVtMbkN4Kvo%3D&reserved=0>.
|
@ThorstenBux @Carnaux i think to implement the decompression in jsartoolkit5, we should in loadNFTMarker in ARToolKitJS.cpp add a check if the extension is |
I will try it later today. @kalwalt which jsartoolkit repo I should use? |
I think we can start with https://github.com/artoolkitx/jsartoolkit5/ what do you think @ThorstenBux? |
@kalwalt @ThorstenBux Can you test if it builds? https://github.com/Carnaux/jsartoolkit5/tree/compression I'm getting an error because the command line is too long, I found a workaround, but it is only for windows, so I presume that you guys won't have the same issue if it is the case I will write a Windows condition on makem.js. And I will create a submodule for Zlib as well. |
I would test @Carnaux, can't say so much for the issue you encountered. |
The test is just to tell if Linux/Mac has the same issue, or if it is a Windows exclusive issue. |
ok also i noted that decompressMarkers is empty, i understood that you need only a confirm of your issue. |
I get this error: and looks at thiese lines:
|
After fixing this i can not compile it, see the gist |
Thanks for the feedback!!!!! |
My suspicions were right, I'm getting memory issues, I tried with a struct, but I was getting an unreachable error. Can you guys give it a look? I will upload what I have so far. Testing with: nft_threejs_wasm.html, just to see if it loads or not. |
Haven't had the time to look at this, i hope soon to have the time... 🙂 |
The decompression is working!! But i'm having issues with this clone of jsartoolkit5:
and
|
I've just seen that the camera_para.dat isn't loading |
that's a real strange error never encountered before, do you have made changes also in other part of the code other than in the loader? |
It was the two .dat files included, I don't know why they didn't work, but I got another one and it worked fine. |
I committed the last changes, and now we have the .zft file working! |
Super Daniel! that's a very nice news, and how is the performances? |
I only tested on my PC, but it is fast, the decompression code didn't cost anything. The memory issue before was a memory leak, I was saving the wrong data type to the marker files and that caused a memory leak somewhere in the loading of KPM data. Please test it and send me feedback, I believe that there are some minor code enhancements, but it is all working. |
I saw you comment in the other issue, I will test tomorrow for sure. See you soon with some data to compare. 🙂 |
I tested on both Desktop and Mobile they work well on both. Tested with my Android (7.1.2) Wiko View model and the total time download of pinball.zft takes minimum 420 ms and maximum 507 ms on my device. I think is less than that the old approach. This at least is my impression, but i need to confirm this with some tests. |
With the old approach ( loading .fset3 .iset .fset) instead it takes minimun 537 and maximum 719 ms. |
I didn't make yet this comparison, but i should do indeed. Maybe ths evening 😃 |
Do you think it is ready for a new PR? |
I already posted this question in the NFT-Marker-Creator issue tracker. To keep tracks and find resources, solutions or anything else.
The text was updated successfully, but these errors were encountered: