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
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Updating Focus Indicator causing camera viewfinder to flicker

I have been able to learn from a sample called Focus (bb jam 2012) which shows how to handle focus with camera. 

 

My problem is when updating my Focus indicator (either it's image or visibility) the viewfinder window will sometimes kind of flicker from the right side or left side of the screen. It's difficult to describe but not nice compared to a smooth view of the viewfinder which is what I get when not touching the focus indicator when status events occur.

 

Appreciate any suggestions how to make this flickering go away and still keep updating my indicator. code is below.

 

if(status == CAMERA_STATUS_FOCUS_CHANGE)
	{
		camera_region_t region;
		camera_focusstate_t state;
		camera_get_focus_state(mCameraHandle,
				&state,
				&region);
		if (state == CAMERA_FOCUSSTATE_LOCKED) {

			mFocusIndicator->setImage(focused_image);
		} else if(state == CAMERA_FOCUSSTATE_SEARCHING)
		{
			// the focus is not locked, clear the visual indicator.


			mFocusIndicator->setImage(non_focused_image);
		}
	}

 

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

Re: Updating Focus Indicator causing camera viewfinder to flicker

[ Edited ]

What device and OS version are you testing on?  (Settings->About->Model Number & OS Version)

 

Do you see this flicker with the stock Focus sample app too?

Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Updating Focus Indicator causing camera viewfinder to flicker

Thanks for your reply Sean,

 

I don't see this on focus sample app itself. I am using os version 10.0,10.90 and device is z10 stl100-2 but I know it's probably irrelevent knowing that the focus app isn't producing this issue.

 

The differences between my app and focus app is I am manually setting focus mode to CAMERA_FOCUSMODE_CONTINUOUS_AUTO as I think this is what I need and I am also dealing with orientation to keep the viewfinder displayed properly depending on orientation. I do this in a modified version of applyRotations() which I include. One more thing that I notice is it seems to happen more when I point the device towards a light but that might be just coincidence. I'll keep digging as I know it's difficult to help me without see full code and problem occuring but if there is anything someone thinks might be causing a problem due to something I haven't set in camera settings then let me know and ill give it a try.

 

It's weird that it doesn't happen if I don't set visibility or image of imageview.

 

if (mViewfinderPhotoWindow->isBoundToWindow()) {
			camera_set_device_orientation(mCameraHandle, (360 - (OrientationSupport::instance()->displayDirection())) % 360);


			screen_window_t win = mViewfinderPhotoWindow->windowHandle();
			screen_set_window_property_iv(win, SCREEN_PROPERTY_ROTATION, (int*)&mWindowAngle);
			int i = mShouldMirror;
			screen_set_window_property_iv(win, SCREEN_PROPERTY_MIRROR, &i);
			if (flush) {
				
				screen_context_t screen_ctx;
				screen_get_window_property_pv(win, SCREEN_PROPERTY_CONTEXT, (void **)&screen_ctx);
				screen_flush_context(screen_ctx, 0);
			}
		}

 

Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Updating Focus Indicator causing camera viewfinder to flicker

The actual line of code which seems to cause the issue is screen_set_window_property_iv(win, SCREEN_PROPERTY_ROTATION, (int*)&mWindowAngle); in my modified version of applyRotation but if I don't include it the viewfinder doesn't display upright. Is this correct way to handle rotation for taking pictures?

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

Re: Updating Focus Indicator causing camera viewfinder to flicker

If you are just taking photos, you can typically ignore all of the CAMERA_IMGPROP_ROTATION stuff actually.

camera_set_device_orientation() will take care of saving JPEGs with the correct EXIF tags to ensure they can be displayed properly.

If you are doing a video-mode viewfinder, then you will need to deal with CAMERA_IMGPROP_ROTATION values, but it's possible to defer those settings until you actually need to record video.  I think the Rotation sample handles thi

 

It sounds like what you are experiencing is a race between the navigator re-orient effect and the need to rotate your screen window.  You can experiment with tying the updates to different navigator events.. there is somethng like a "about to rotate", "rotating", "finished rotating" series of signals you can listen for.. maybe in my sample I didn't pick the best one to key off of.

Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Updating Focus Indicator causing camera viewfinder to flicker

Thanks Sean.

 

I have set a break point in each of the 3 orientation listener functions but none of them get called when the flickering occurs nor am I actually rotating the device when the flickering occurs.

 

This only occurs when showing camera for taking a picture and I am ignoring CAMERA_IMGPROP_ROTATION and I am using camera_set_device_orientation when the camera window (onWindowAttached) is shown or when orientation occurs (both in modified version of applyRotation shown above).

 

 I also have the call screen_set_window_property_iv(win, SCREEN_PROPERTY_ROTATION, (int*)&mWindowAngle); in there otherwise the window isn't shown upright, but setting the rotation this way (when window is initially shown) seems to be the cause for the flickering. 

 

A question I need answering - Is this the correct way to rotate what the user is seeing when camera initially shown or when a chagne occurs - screen_set_window_property_iv(win, SCREEN_PROPERTY_ROTATION, (int*)&mWindowAngle);?

 

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

Re: Updating Focus Indicator causing camera viewfinder to flicker

ah.. so you're only updating the window rotation when things start, or when you rotate the device, but the flickering happens at some other time?

 

if you feel like sharing your project files w/ me, I can take a look on different hardware here and if there seems to be a bug I can get it in front of the right team.

 

And to answer your last question - yes, you should only need to update the rotation of the window the way you mentioned.  (if you are rotating it using the camera APIs, then you need to look at things like swapping width & height, but not in your case).

 

Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Updating Focus Indicator causing camera viewfinder to flicker

Thanks Sean for the confirmation,

 

I have spotted the difference between my app and the focus app which causes this problem - its because my camera page which contains the foreignwindowcontrol is added to a navigationpane, if I just use Application::instance()->setScene to show the camera page the flickering never occurs.

 

I found this out by including all my relevent rotation code into the focus sample to send to you but the problem never occured - thats when i realised the only difference left was navigationpane.

 

Do I have to redesign the way I show my camera page - I liked having the peek and back menu so I'd rather stick with navigationpane if poss.

Please use plain text.
Developer
danielleCoder
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Updating Focus Indicator causing camera viewfinder to flicker

[ Edited ]

I have attached my modified version of Focus sample app containing this issue - its either to do with NavigationPane or Its ActionBar as they are what I needed to include in the Focus sample to reproduce this.

 

I sometimes have to keep the viewfinder showing for a couple of minutes to see this happening or then sometimes it will occur a few seconds after starting the camera.

 

Thanks.

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

Re: Updating Focus Indicator causing camera viewfinder to flicker

ok cool, thanks.  I will try to look at this when I get a chance in the next few days.

 

I don't think you should need to redesign your app layout.  this sort of thing should "just work".  there may be some odd graphics race happening somewhere.. not sure yet.

 

Cheers,

Sean

Please use plain text.