Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Contributor
kerdum
Posts: 8
Registered: ‎09-15-2012
My Device: BB10 Dev Alpha
My Carrier: Rogers
Accepted Solution

Recording with Video Camera

[ Edited ]

Hi,

 

I'm not sure if maybe the Camera Documentation is not aligned with the API documentation. I was wondering if someone could guide me with getting the Dev Alpha camera to record. The Following code gets the Camera started properly.

 

// Initialize Video Cam
	QmlDocument *qml = QmlDocument::create("asset:///videoCam.qml");
	mVideoCam = qml->createRootObject<Page>();
	Camera *camera = mVideoCam->findChild<Camera*>("myCamera");
	camera->open(CameraUnit::Front);

 And then I push the camera into view with:

 

mNavPane->push(mVideoCam);

 The camera is up and running. What is not clear to me is I get the following error when I "startVideoCapture()":

 

Dec 16 22:22:17.933 com.example.DiveBook.testDev_le_DiveBook7e1553ee.15999178              default    301  CamControllerInternal::StartVideoRecording Error -> Invalid vf mode. (vf mode:1)

Dec 16 22:22:17.933 com.example.DiveBook.testDev_le_DiveBook7e1553ee.15999178              default    301  CamControllerInternal::ExecuteCommand STARTVIDEORECORDING = result (15)

Dec 16 22:22:17.933 com.example.DiveBook.testDev_le_DiveBook7e1553ee.15999178              default    300  void bb::cascades::multimedia::CameraPrivate::onRecordingFailed(CamResult) called.
Dec 16 22:22:17.933 com.example.DiveBook.testDev_le_DiveBook7e1553ee.15999178              default   9000  OrientationSupportPrivate::setSupportedDisplayOrientation: displayOrientation: All 
Dec 16 22:22:17.933 com.example.DiveBook.testDev_le_DiveBook7e1553ee.15999178              default   9000  OrientationSupportPrivate::setSupportedDisplayOrientation: successfully changed to All 
Dec 16 22:22:17.934 com.example.DiveBook.testDev_le_DiveBook7e1553ee.15999178              default   9000  onVideoCaptureFailed signal received with error 3

 I imagine "Invalid VF Mode" mean I have to set something correctly related to my viewfinder? Can someone show me and example?

 

here is my videoCam.qml for reference:

// Default empty project template
import bb.cascades 1.0
import bb.cascades.multimedia 1.0

Page {
    // This is the camera control that is defined in the cascades multimedia library.
	Camera {
	    id: camera
	    objectName: "myCamera"
	    
	    onTouch: {
            if (event.isDown() && !camera.videoCaptureStarted()) {
                // Take photo
                startVideoCapture();
            }
        }
	    
	    // When the camera is opened we want to start the viewfinder
        onCameraOpened: {
            camera.startViewfinder();
        }

        // There are loads of messages we could listen to here.
        // onPhotoSaved and onShutterFired are taken care of in the C++ code.
        onCameraOpenFailed: {
            console.log("onCameraOpenFailed signal received with error " + error);
        }
        onViewfinderStartFailed: {
            console.log("viewfinderStartFailed signal received with error " + error);
        }
        onViewfinderStopFailed: {
            console.log("viewfinderStopFailed signal received with error " + error);
        }
        onVideoCaptureFailed: {
            console.log("onVideoCaptureFailed signal received with error " + error);
        }
	}
}

 

 

Thanks,

Kerdum

Please use plain text.
New Contributor
kerdum
Posts: 8
Registered: ‎09-15-2012
My Device: BB10 Dev Alpha
My Carrier: Rogers

Re: Recording with Video Camera

I think I solved it. I had to populate an instance of CameraSettings class and then apply it to my camera using "camera.applySettings()"

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Recording with Video Camera

right.. I believe you need to select "Video" mode in your settings.. by default, the Qt Camera runs in photo mode.

Please use plain text.
Contributor
paul_shah
Posts: 17
Registered: ‎02-01-2013
My Device: Bold 9900
My Carrier: Bell

Re: Recording with Video Camera

Could you provide the sample code for initializing, populating and applying the Camera settings? 

 

Thanks! 


kerdum wrote:

I think I solved it. I had to populate an instance of CameraSettings class and then apply it to my camera using "camera.applySettings()"


 

Please use plain text.
Contributor
paul_shah
Posts: 17
Registered: ‎02-01-2013
My Device: Bold 9900
My Carrier: Bell

Re: Recording with Video Camera

I tried this: 

 

if (!qml->hasErrors()) {

        // The application Page is created from QML.

        Page *appPage = qml->createRootObject<Page>();

 

        if (appPage) {

 

            mCamera = appPage->findChild<Camera*>("myCamera");

            QObject::connect(mCamera, SIGNAL(shutterFired()), this, SLOT(onShutterFired()));

 

            /*mCameraSettings->setCameraMode(CameraMode::Video);

            mCameraSettings->setFocusMode(CameraFocusMode::Auto);

            mCameraSettings->setShootingMode(CameraShootingMode::smileyfrustrated:tabilization);

 

            bool settingsApplied = mCamera->applySettings(mCameraSettings);*/

 

           // if (settingsApplied)

            mCamera->open(CameraUnit::Rear);

 

            // Set the application scene and connect the camera's shutterFired signal to our slot function

            Application::instance()->setScene(appPage);

        }

    }

 


I commented out the section with the cameraSettings because if I leave that code uncommented, the app keeps crashing. Do you know what I am doing wrong? 

 

Without that, the app starts up in a viewfinder. I cannot seem to get the syntax correct for camerasettings. Any suggestions?

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Recording with Video Camera

[ Edited ]

where do you initialize mCameraSettings?  it's probably an uninitialized pointer to nowhere, which would explain your crash.

 

https://developer.blackberry.com/cascades/reference/bb__cascades__multimedia__camera.html#function-g...

 

you need to open a camera before you can retrieve it's settings.  and you need to apply the settings before you start the viewfinder.

Please use plain text.
Contributor
paul_shah
Posts: 17
Registered: ‎02-01-2013
My Device: Bold 9900
My Carrier: Bell

Re: Recording with Video Camera

I am initializing that pointer in the header file. 

 

CameraSettings *mCameraSettings; 

 

I think you pointed out my problem. I think I was applying the settings before opening the camera. That might've been my mistake. 

 

Thanks:smileyhappy:

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Recording with Video Camera

CameraSettings *mCameraSettings;

 

that does not initialize anything. it just declares it.  mCameraSettings most likely is a null or garbage pointer.

 

 

Please use plain text.
BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer
My Carrier: other

Re: Recording with Video Camera

you most likely want to do something like:

 

CameraSettings camsettings;   // declare this in your header if you want.

// initialize current settings (retrieved from camera) camera->getSettings(&camsettings);
// change the settings however you want ....

// apply new settings to the camera
camera->applySettings(&camsettings);

 Declaring a pointer to CameraSettings that are not initialized probably doesn't help you, as getSettings() does not allocate a new instance.. it only populates the instance you provide.

 

Cheers,

Sean

Please use plain text.
Contributor
paul_shah
Posts: 17
Registered: ‎02-01-2013
My Device: Bold 9900
My Carrier: Bell

Re: Recording with Video Camera

Ok will try that out and let you know if that works.

Please use plain text.