Hi all,
I have been working on an addon that uses the player's webcam. I have an in-game procedure for testing face detection, that works in the following way:
- The binary module is prompted to grab the current camera frame and estimate the rectangle that contains the player's face
- That rectangle is then used to crop the image
- The cropped image is displayed in-game and the user is asked whether this is correct
Example:
[IMG]http://i62.tinypic.com/2lxa69i.png[/IMG]
Currently I do this by writing the cropped image to a file (stored in garrysmod/data/my_temp/) and passing the newly generated file name to LUA. I generate a new file name because I noticed that the game caches assets, i.e. the same file name is not loaded a second time even if the file has changed. The problem I'm having is that whenever a folder is modified, whether its garrysmod/data or garrysmod/addon/my_addon/, the game freezes for about 10 seconds while reloading the folder, even when the folder only contains one image. I'm looking for a way around this, so I have the following questions:
Does anyone know why the game freezes for so long when modifying a data or addon folder, even when the folder itself only contains one image?
Is there a way to load an image from disk in LUA, that is not in the data or addon folder?
Is there a better way to send image data from binary module to LUA?
I need the image data for a Derma image, by the way. Any help is appreciated!
How do you do this? I've been looking into this but couldn't find an answer...
have you tried to disable lua autorefresh?
You can load the image in a HTML element using base64 images.
[code]
<img src="data:image/png;base64,SOME BASE64 TEXT..." />
[/code]
Regarding getting webcam data from binary to lua, have you tried .. returning the actual data as a string? (in this case, a base64 string).
Have you tried creating a texture and returning it as ITexture from your module? Have you tried using rendertargets?
Thanks all, I'll try all your suggestions out! :) Robotboy, do you have an example of how to create a texture from a module?
MrPlonker, I use OpenCV, an open source library for reading from webcam and writing to a PNG file. So first step would be to learn how to use OpenCV: [url]http://docs.opencv.org/doc/tutorials/tutorials.html[/url]
Then to include OpenCV in your module, make a "makeSnapshot" function in C++ and register it to LUA. Afterwards, load the PNG in LUA. PM me if you need any help with that. :)
[QUOTE=NisshokuZK;44427150]Thanks all, I'll try all your suggestions out! :) Robotboy, do you have an example of how to create a texture from a module?
MrPlonker, I use OpenCV, an open source library for reading from webcam and writing to a PNG file. So first step would be to learn how to use OpenCV: [url]http://docs.opencv.org/doc/tutorials/tutorials.html[/url]
Then to include OpenCV in your module, make a "makeSnapshot" function in C++ and register it to LUA. Afterwards, load the PNG in LUA. PM me if you need any help with that. :)[/QUOTE]
You could take the PNG it creates and modify it to return a base64 string, and then make that return on client.
The converting to Base64 string approach works perfectly, thanks guys!
this could be abused so much
nonetheless this is really cool
Sorry, you need to Log In to post a reply to this thread.