Corona-ARKit for augmented reality

Hey,

I ported iPhone ARKit to Corona SDK as didn’t find anybody else doing it already. It’s based on the camera type fill and seems to work quite nicely already even though there are issues with e.g. rotation. 

One particular thing bothers me though.

As I’ve understood, it should be enough to do the “fill” assignment once, i.e:

displayView.preview.fill = { type="camera" }

but the perfomance seems to be worse than when I put it into enterFrame function, ie:

function c:enterFrame() if not isSimulator then displayView.preview.fill = { type="camera" } end end

Any thoughts why this would be?

Oh, and the repo is here: https://github.com/jyrkih/arkit-corona

Jyrki

There may be a difference between “You only need to add it once” vs. “you can add it multiple times”

What happens if you add it outside the enterFrame function?

Rob

Hey,

as far as I can tell, if I do it only once, I get significantly lower fps for the camera texture fill. So it basically skips over some frames when I rotate the device. When done in enterFrame, the performance is actually pretty good. And this on iPad 2.

Jyrki

Hey Jyrki,

Very good job porting the ARKit library. Were you successful to get good performance mapping GPS point into a real time camera feed ? Do you have some sample code you would be ready to share of how you did it ?

thanks

Nicolas

Howdy,

The perf is pretty good. The only thing I have is still the same as with question above – my *.fill = {type=“camera”} is in enterFrame(), where I think it shouldn’t be.

anyway, the kit is here: https://github.com/jyrkih/arkit-corona, sample is main.lua file basically. 

If you look at it, it’s pretty simple:

-- require module local ar = require("arkit.arkit") print(ar.deviceSupportsAR()) local isSimulator = system.getInfo("environment")=="simulator" -- setup POI array local pointsOfInterest = { {longitude = -73.994901,latitude = 41.145495,altitude = 30, title="New York"}, {longitude = 24.9354500,latitude = 60.1695200,altitude = 30, title="Helsinki"}, {longitude = 33.0788,latitude = 68.969,altitude = 30, title="Murmansk"}, {longitude = -3.696111,latitude = 40.416667,altitude = 30, title="Madrid"}, } local ds = display.getCurrentStage() local delegate = {} local \_locations=nil local \_userLocation = nil local controller = nil -- this function show the marker local function setMarkerView(coord) coord.displayView = display.newGroup() coord.displayView.anchorChildren = true coord.displayView.x = 0 coord.displayView.y = 0 local c = display.newCircle(coord.displayView, 0, 0, 20) c:setFillColor(1,0,0,0.5) local opts = { text = coord.title, parent = coord.displayView, x = 0, y = 30, --required for multi-line and alignment font = native.systemFont, fontSize = 18 } display.newText(opts) end -- register points of interest to the AR controller local function setupLocations() \_locations = {} for i=1, #pointsOfInterest do local poi = pointsOfInterest[i] local c1 = ar.argeocoordinate:coordinateWithLocation(poi, poi.title) c1:calibrateUsingOrigin(\_userLocation) setMarkerView(c1) controller:addCoordinate(c1) \_locations[#\_locations+1] = c1 end end -- callback for location events function delegate:location(event) local init = false if not \_userLocation then init = true end \_userLocation = event if init then pcall(self.geoLocations) end --print("delegate.location()", event.longitude, event.latitude, event.altitude) end --callback for heading event function delegate:heading(event) --print("delegate.heading()", event) end --callback for orientation event function delegate:orientation(event) --print("delegate.orientation()", event.type) end --accessor function delegate:geoLocations() if \_locations == nil then setupLocations() end return \_locations end -- ar controller setup, given delegate object as callback controller = ar.arcontroller:new(ds, delegate) -- configuration here controller.radarRange = 3000 controller:setShowsRadar(true) controller.onlyShowItemsWithinRadarRange = true

You can also check objective-C ARKit fork:

https://github.com/nielswh/iPhone-AR-Toolkit

and especially

https://github.com/chrjs/iPhone-AR-Toolkit

for reference. I’m still to complete most configuration options for controller, so it’s WIP.

Jyrki

There may be a difference between “You only need to add it once” vs. “you can add it multiple times”

What happens if you add it outside the enterFrame function?

Rob

Hey,

as far as I can tell, if I do it only once, I get significantly lower fps for the camera texture fill. So it basically skips over some frames when I rotate the device. When done in enterFrame, the performance is actually pretty good. And this on iPad 2.

Jyrki

Could you share the screenshots of your app using the ARKit?

Hey Jyrki,

Very good job porting the ARKit library. Were you successful to get good performance mapping GPS point into a real time camera feed ? Do you have some sample code you would be ready to share of how you did it ?

thanks

Nicolas

Howdy,

The perf is pretty good. The only thing I have is still the same as with question above – my *.fill = {type=“camera”} is in enterFrame(), where I think it shouldn’t be.

anyway, the kit is here: https://github.com/jyrkih/arkit-corona, sample is main.lua file basically. 

If you look at it, it’s pretty simple:

-- require module local ar = require("arkit.arkit") print(ar.deviceSupportsAR()) local isSimulator = system.getInfo("environment")=="simulator" -- setup POI array local pointsOfInterest = { {longitude = -73.994901,latitude = 41.145495,altitude = 30, title="New York"}, {longitude = 24.9354500,latitude = 60.1695200,altitude = 30, title="Helsinki"}, {longitude = 33.0788,latitude = 68.969,altitude = 30, title="Murmansk"}, {longitude = -3.696111,latitude = 40.416667,altitude = 30, title="Madrid"}, } local ds = display.getCurrentStage() local delegate = {} local \_locations=nil local \_userLocation = nil local controller = nil -- this function show the marker local function setMarkerView(coord) coord.displayView = display.newGroup() coord.displayView.anchorChildren = true coord.displayView.x = 0 coord.displayView.y = 0 local c = display.newCircle(coord.displayView, 0, 0, 20) c:setFillColor(1,0,0,0.5) local opts = { text = coord.title, parent = coord.displayView, x = 0, y = 30, --required for multi-line and alignment font = native.systemFont, fontSize = 18 } display.newText(opts) end -- register points of interest to the AR controller local function setupLocations() \_locations = {} for i=1, #pointsOfInterest do local poi = pointsOfInterest[i] local c1 = ar.argeocoordinate:coordinateWithLocation(poi, poi.title) c1:calibrateUsingOrigin(\_userLocation) setMarkerView(c1) controller:addCoordinate(c1) \_locations[#\_locations+1] = c1 end end -- callback for location events function delegate:location(event) local init = false if not \_userLocation then init = true end \_userLocation = event if init then pcall(self.geoLocations) end --print("delegate.location()", event.longitude, event.latitude, event.altitude) end --callback for heading event function delegate:heading(event) --print("delegate.heading()", event) end --callback for orientation event function delegate:orientation(event) --print("delegate.orientation()", event.type) end --accessor function delegate:geoLocations() if \_locations == nil then setupLocations() end return \_locations end -- ar controller setup, given delegate object as callback controller = ar.arcontroller:new(ds, delegate) -- configuration here controller.radarRange = 3000 controller:setShowsRadar(true) controller.onlyShowItemsWithinRadarRange = true

You can also check objective-C ARKit fork:

https://github.com/nielswh/iPhone-AR-Toolkit

and especially

https://github.com/chrjs/iPhone-AR-Toolkit

for reference. I’m still to complete most configuration options for controller, so it’s WIP.

Jyrki

Could you share the screenshots of your app using the ARKit?