shape.fill = { type="camera" }

So I’m trying to live feed from the camera, but its not working.

on IOS it takes a snap in the 1st second the app opens and then freezes (front and back cam)

on android its just a blank screen (front and back cam)

--display.setDefault( "cameraSource", "back" )  --back-facing camera display.setDefault( "cameraSource", "front" )   --front-facing camera local shape = display.newRect( dpw/2,dph/2, 320, 480 ) shape.fill = { type="camera" }

bought app have the required permissions i think… not sure what im doing wrong

Putting up your build.settings with the permissions would help to evaluate that portion.

FYI this isn’t possible on Android. I’ve been able to get this functionality working about 6 months ago on iOS though. Could you post your i-Device specs as well?

Hi Alex it a samsung s4 and iphone 6 plus

build.settings :

android = {         googlePlayGamesAppId = "\*\*\*\*\*", usesPermissions = {          "android.permission.INTERNET",          "android.permission.ACCESS\_NETWORK\_STATE",          "android.permission.READ\_PHONE\_STATE",          "com.android.vending.BILLING",          "android.permission.CAMERA",          "android.permission.WRITE\_EXTERNAL\_STORAGE", }, }, iphone = { plist = {        CoronaUseIOS7IPadPhotoPickerLandscapeOnlyWorkaround = true,        CoronaUseIOS6IPadPhotoPickerLandscapeOnlyWorkaround = true,        CoronaUseIOS7LandscapeOnlyWorkaround = true,        CoronaUseIOS6LandscapeOnlyWorkaround = true,                  

I don’t know why I asked for your build.settings, as it doesn’t work on Android and iOS wouldn’t be a problem.

My implementation was basically, exactly the same as yours:

local rectLeft = display.newRect( display.contentWidth/4.15, display.contentCenterY, display.contentHeight/1.35, display.contentWidth/2) rectLeft.fill = { type = "camera" } rectLeft.rotation = -90

Have you tried to creating and destroying the object with the fill inside of an enterFrame listener? I don’t know how it would affect performance, but perhaps it would be a good way to confirm that you can use the fill() API throughout your app? Other than that, I’m not sure what could be causing the problem on iOS.

oky i created this little test app: 

ps: the  fill() API on rect2 and rect3 work fine (rect2 : create cam) (rect3 : deletes cam )

ps2: the ‘shape’ (cam fill) returns a black screen

local storyboard = require( "storyboard" ) local scene = storyboard.newScene() dpw =   display.contentWidth dph =   display.contentHeight cw = contentWidth function scene:createScene( event ) local group = self.view local bg1 = display.newRect(dpw/2,dph/2,dpw,dph) bg1:setFillColor( 0.96,0.96,0.91 ) group:insert( bg1 ) local paint = { 0.5 } local rect2 = display.newRect( 0, 0, 100, 30 ) rect2.fill = paint rect2.x = dpw - dpw + rect2.contentWidth/2 + 5 rect2.y = dph - rect2.contentHeight/2 - 5 local rect3 = display.newRect( 0, 0, 100, 30 ) local paint = {     type = "composite",     paint1 = { type="image", filename="texture1.png" },     paint2 = { type="image", filename="dust.png" }      } rect3.fill = paint rect3.x = dpw - rect2.contentWidth/2 - 5 rect3.y = dph - rect2.contentHeight/2 - 5 rect3.fill.effect = "composite.average" makecamC = 0 function makecam() if makecamC == 0 then --display.setDefault( "cameraSource", "front" )   --front-facing camera display.setDefault( "cameraSource", "back" )  --back-facing camera shape = display.newRect( dpw/2,dph/2, 320, 480 ) shape.fill = { type="camera" } makecamC = 1 else  print("makecam else") end end function dellcam() if makecamC == 1 then  shape:removeSelf() shape = nil makecamC = 0 else  print("dellcam else") end end rect2:addEventListener( "tap", makecam ) rect3:addEventListener( "tap", dellcam ) end--end function scene:enterScene( event ) local group = self.view end function scene:willEnterScene( event ) local group = self.view end function scene:exitScene( event ) local group = self.view end function scene:didExitScene( event ) local group = self.view     end function scene:destroyScene( event ) local group = self.view end --------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "willEnterScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "didExitScene", scene ) scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene

I made a camera app with iPhone/iPad. It worked great. I ran into the same problem you are having. 

Unfortunately realtime shapeFill Camera with Android will not work. :confused:  something to do with OpenGL? But iOS works great.

you need:

function updateFrames( event ) if shape then shape:invalidate() end end Runtime:addEventListener( "enterFrame", updateFrames );

to make sure it invalidates the shape and forces an update for that fill every frame. 

 I put that update in the main contents, and I put the Runtime in the scene:show area (after shape was made) to get it going. make sure to remove it when you leave the scene 

try that out.   :slight_smile:

@Lava thanks for the tip :smiley:

Putting up your build.settings with the permissions would help to evaluate that portion.

FYI this isn’t possible on Android. I’ve been able to get this functionality working about 6 months ago on iOS though. Could you post your i-Device specs as well?

Hi Alex it a samsung s4 and iphone 6 plus

build.settings :

android = {         googlePlayGamesAppId = "\*\*\*\*\*", usesPermissions = {          "android.permission.INTERNET",          "android.permission.ACCESS\_NETWORK\_STATE",          "android.permission.READ\_PHONE\_STATE",          "com.android.vending.BILLING",          "android.permission.CAMERA",          "android.permission.WRITE\_EXTERNAL\_STORAGE", }, }, iphone = { plist = {        CoronaUseIOS7IPadPhotoPickerLandscapeOnlyWorkaround = true,        CoronaUseIOS6IPadPhotoPickerLandscapeOnlyWorkaround = true,        CoronaUseIOS7LandscapeOnlyWorkaround = true,        CoronaUseIOS6LandscapeOnlyWorkaround = true,                  

I don’t know why I asked for your build.settings, as it doesn’t work on Android and iOS wouldn’t be a problem.

My implementation was basically, exactly the same as yours:

local rectLeft = display.newRect( display.contentWidth/4.15, display.contentCenterY, display.contentHeight/1.35, display.contentWidth/2) rectLeft.fill = { type = "camera" } rectLeft.rotation = -90

Have you tried to creating and destroying the object with the fill inside of an enterFrame listener? I don’t know how it would affect performance, but perhaps it would be a good way to confirm that you can use the fill() API throughout your app? Other than that, I’m not sure what could be causing the problem on iOS.

oky i created this little test app: 

ps: the  fill() API on rect2 and rect3 work fine (rect2 : create cam) (rect3 : deletes cam )

ps2: the ‘shape’ (cam fill) returns a black screen

local storyboard = require( "storyboard" ) local scene = storyboard.newScene() dpw =   display.contentWidth dph =   display.contentHeight cw = contentWidth function scene:createScene( event ) local group = self.view local bg1 = display.newRect(dpw/2,dph/2,dpw,dph) bg1:setFillColor( 0.96,0.96,0.91 ) group:insert( bg1 ) local paint = { 0.5 } local rect2 = display.newRect( 0, 0, 100, 30 ) rect2.fill = paint rect2.x = dpw - dpw + rect2.contentWidth/2 + 5 rect2.y = dph - rect2.contentHeight/2 - 5 local rect3 = display.newRect( 0, 0, 100, 30 ) local paint = {     type = "composite",     paint1 = { type="image", filename="texture1.png" },     paint2 = { type="image", filename="dust.png" }      } rect3.fill = paint rect3.x = dpw - rect2.contentWidth/2 - 5 rect3.y = dph - rect2.contentHeight/2 - 5 rect3.fill.effect = "composite.average" makecamC = 0 function makecam() if makecamC == 0 then --display.setDefault( "cameraSource", "front" )   --front-facing camera display.setDefault( "cameraSource", "back" )  --back-facing camera shape = display.newRect( dpw/2,dph/2, 320, 480 ) shape.fill = { type="camera" } makecamC = 1 else  print("makecam else") end end function dellcam() if makecamC == 1 then  shape:removeSelf() shape = nil makecamC = 0 else  print("dellcam else") end end rect2:addEventListener( "tap", makecam ) rect3:addEventListener( "tap", dellcam ) end--end function scene:enterScene( event ) local group = self.view end function scene:willEnterScene( event ) local group = self.view end function scene:exitScene( event ) local group = self.view end function scene:didExitScene( event ) local group = self.view     end function scene:destroyScene( event ) local group = self.view end --------------------------------------------------------------------------------- scene:addEventListener( "createScene", scene ) scene:addEventListener( "willEnterScene", scene ) scene:addEventListener( "enterScene", scene ) scene:addEventListener( "exitScene", scene ) scene:addEventListener( "didExitScene", scene ) scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene

I made a camera app with iPhone/iPad. It worked great. I ran into the same problem you are having. 

Unfortunately realtime shapeFill Camera with Android will not work. :confused:  something to do with OpenGL? But iOS works great.

you need:

function updateFrames( event ) if shape then shape:invalidate() end end Runtime:addEventListener( "enterFrame", updateFrames );

to make sure it invalidates the shape and forces an update for that fill every frame. 

 I put that update in the main contents, and I put the Runtime in the scene:show area (after shape was made) to get it going. make sure to remove it when you leave the scene 

try that out.   :slight_smile:

@Lava thanks for the tip :smiley: