clementfarabet / torch-ios

Torch7 for iOS.
Other
196 stars 42 forks source link

how to use image.load("filename") ? #19

Open ghost opened 8 years ago

ghost commented 8 years ago

I have the "error running function `f': ...Example.app/Torch.framework/Resources/image/init.lua:103: attempt to index global 'xlua' (a nil value)". How can I fix this?

kurtjacobsdev commented 8 years ago

Hi @xxleprechaun The code in Image/init.lua calls a specific loader method for each image type (JPG, PNG etc.) Specifically its making a call (in the case of a png) to xlua to require libpng.

if not xlua.require 'libpng' then
      dok.error('libpng package not found, please install libpng','image.loadPNG')
end

My suggestion would be to include xlua when building the iOS framework or depending on what your trying to achieve you could do the image processing using OpenCV (Strictly CPU) or GPUImage (Which takes advantage of the iPhone's GPU). After doing your computation you can then convert this into a tensor and send it over to your lua script?

objectc commented 7 years ago

@woffle I have the same problem. Could you tell me if there's any way to load and save image directly in iOS? How to add libpng, libjpeg to the iOS project?

kurtjacobsdev commented 7 years ago

Right now your best bet would be to load the image using CoreGraphics or CoreImage and do your processing then push that onto the lua stack and do any torch stuff in the script. Although as Soumith has suggested the best thing would be to rebuild the library from the current distro then it should have the latest torch fixes/updates. This project is severely outdated.

objectc commented 7 years ago

@woffle Thanks for you response. I don't know cmake well, is there any example I can see about how to rebuild the library from the latest torch to the iOS framework?