Camera Feeds as Textures

Any news on front Camera usage (iOS or Android)?  It would open some interesting possibilities: having seen Walter’s face on the demo video I would have assumed front camera was going to be working…

@dmekersa – I am getting the same behavior, camera feed not updating, but it does if you suspend/resume (Build 2171).

I noticed something further - If I update the coordinates of *anything* on the screen (move the camera feed rectangle a bit, or even an onscreen button by 1 pixel), then the camera feed updates. But just for 1 frame - while the other object is updating. If you move something a pixel later, again the camera feed updates at that time.

So I’m guessing the camera feed by itself doesn’t trigger the SDK to update/refresh the openGL buffers, or something along those lines.

Something else onscreen must update/move to trigger the cascade of openGL buffer goodness. Well, until coronaLabs starts making live camera feeds force screen updates, me thinks…

I’ve been putting a 1 pixel circle at .004 alpha moving back and forth on the screen to get live camera. Works well enough I suppose…

We will look into this. A possible work-around is to call: display.setDrawMode( “forceRender” ). It overrides several optimizations in rendering to redraw the scene.

@robo – it’s good enough for now, we can move ahead with our code.

I think an important thing here is this:

If we can identify the issues (in beta features like this), and help them to isolate and home in on the technicalities, then we all win.

And CoronaLabs is listening.

So hopefully in the end, we all win.

PS: Note that my meaning is that: CornoaLabs intends for camera feeds / textures to update automatically independent of other objects, and our proposed “workaround” behavior is understood by all, CL too, as temporary until the issues, if any, are resolved. Your mileage may vary.

@mpappas, well said. This has been precisely my experience most recently in the graphics.newOutline API question I posted. 

Hoping for the front camera support  :rolleyes:

By the way I used this to update the camera fill and it works fine:

 local crate = display.newRect(centerX, centerY, 320, 480 )

 crate.fill = { type=“camera” }

  

    local function updateCamera()

        crate.fill = { type=“camera” }

    end

 Runtime:addEventListener(“enterFrame”, updateCamera)

Does anybody have crash after removing display object with camera feed?

I don’t how to remove camera feed.

For gits and shiggles, I added this to my game and it’s rather cool, but I’d really like to get front-camera support as well.  I’ll see if there’s a crash when trying to remove it, but I figure maybe just change the fill before deleting the display object?

What do you do to keep the live feed updated? I heard someone say they add a pixel and move it some. Can you show me what you do?

Thanks!

It just so happens that my background image was constantly moving with the accelerometer, and i had a game loop that performed this every 100ms, so I never had a problem with getting a live feed.

transition.cancel( skyGroup.trans ) skyGroup.trans = transition.to( skyGroup, { time = 100, x = 50 \* ( 0.5 - accel.xGravity ), y = 50 \* ( 0.5 - accel.yGravity ) } )

regarding the landscape vs portrait issue : I created a shape with the camera feed texture and width = wanted_height, height = wanted_width and then just rotated it -90 °, and it seems to work :slight_smile: I also wobbled a pixel to get the feed in realtime and not just one frame at a time. 

Oh, another bug I thought I saw posted about the feeds, but after looking back, I don’t see it mentioned by anyone, so while we’re piling on the feeds here… Anyone else seeing this one?

I put the feed on a rectangle. Great, works good (as long as something else is updating on screen of course, otherwise the feed never updates – already discovered). Put poverlays on top, works great. Mask the feed object, works great. Everything works great… Until.

The user changes screens, and I call display:remove() or object:removeSelf(). Shortly I release() the screen that had the feed (and construct/display the new screen), I get a hard crash on iOS – “Bus Error: 10”.

I had tried several ways to disengage the feed from the OS before the remove() (like setting isVisible = false, setting.fill = “” / nil, using a timer.delay to allow the graphics update, etc), but couldn’t isolate a method that would get around it…  So I switched to the “if you can’t beat them, join them” strategy again (like for the other bug, just keep something moving)…

To prevent the crash (actually to prevent the removal of the feed), when the screen with the feed exits it now creates a global feedgroup and inserts the feed rect into it, then places the group object WAY offscreen so it wont be seen, makes it invisible, etc. (Next time it reloads it checks if the feed already exists, and re-uses it).

With both bugs (feed not updating, and the bus error bug), I’ve got more workaround code than I’d like, but hey, I’m still moving forward onto more screens.

Anyways – anyone else seeing bus error 10: when removing your feed yet?

Did not try yet… Why don’t you use Composer and do not recycle the scene when hidden (it keeps the objects in memory, just hide them)?

You should submit a sample to bug report no? It could help to get this feature fixed. It’s amazing how new features are published and then not updated like this… I got a similar issue with the iTunes plugin, I had to create a project to show the bug, I hope they will fix one day…

+1 for front facing camera

I definitely note for the landscape feature. But mihal’s solution of rotating it may work for now. I plan to try this tonight.

Warren

I just made a simple code here and also saw the problem of the camera not refreshing.

But then I downloaded the Corona Camera Fill Sample code and it worked fine.

Just sad that it sill doesn’t support Front Camera and Android.

Any news on front Camera usage (iOS or Android)?  It would open some interesting possibilities: having seen Walter’s face on the demo video I would have assumed front camera was going to be working…

Hoping for the front camera support  :rolleyes: