Log in or register to post comments

Frame Marker Camera Focus

August 29, 2013 - 6:19am #1

system: windows 7

develope platform : android

software : Unity 4.2

vuforia version : SDK V2.6

 

Hello every one.

I am having problems with the focus of my tablet while using the FrameMarkers.

I have already build something using the Target Image method and it works great.

But now i am trying the same with 4 FrameMarkers, but i find the performance a bit dissapointing.

I blame this on the fact that my camera is not focussing good enough. (not sure though)

 

I have added the "CameraDeviceMenu"script , but it seems my tablet doesn't support the autofocus option.

the problem is that when i use the imageTracker method it DOES autofocus.

So anybody has an idea on how to solve this?

 

Thanks in advance!

 

Frame Marker Camera Focus

September 6, 2013 - 11:37am #6

Yes, the camera image is slightly "zoomed" w.r.t. the whole camera image; this is because the resolution of the camera image is not necessarily the same as the screen resolution, and as a consequence, the aspect ratio (width / height ratio) can also be a bit different from the screen aspect ratio.

To compensate the aspect ratio difference, (and to avoid image distortions) the rendered camera image is slightly magnified so to fit one dimension (either the width or the height, whichever fits best) and the other dimension is "cropped" (or if you like, we may say that a certain part is rendered off-screen).

However the actual "zoom" should be fairly small.

 

 

Frame Marker Camera Focus

September 6, 2013 - 11:22am #5

Hi AlessandroB

Thanks for your help/reply again.

 

I have tested your code and it seems to work a little bit better then before.

BUT

i found that it is not the focus quality which is different, but rather then the whole image seems a bit zoomed (if i compare this to a normal photograph camera view) is this correct? (i mean does vuforia do that?)

 

Thanks again!

 

It is I

Frame Marker Camera Focus

September 3, 2013 - 6:54am #4

Hi AlessandroB

Thanks for your reply

I have tried the CameraDeviceMenu.cs script (i can not find the imagetrackerMenu script)

and it seems autofocus is not suppported on my device (samsung galaxy tab 10.1 P7500)

the CameraDevice.cs script has more focus options, but when i try to add that to my ARcamera i get the message "The script class can't be abstract!"

 

I am not a real programmer/scripter so maybe i am doing something wrong

 

Thanks in advance

 

ItisI

 

EDIT---------

I found the imageTrackerMenu.cs script in the imagetracker example and imported it into my scene.

However when i double tab the screen i don't get ANYTHING. i thought it would show me a menu from where i could choose aditional optiongs like camera focus mode and image tracker - image.

What i did is import the script and placed it onto my AR-camera (just like in the example scene)

did is mis something?

 

Thanks in advance

 

ItisI

Frame Marker Camera Focus

September 3, 2013 - 6:54am #3

You can try this code, which allows testing all the focus modes and provides some on-screen messages telling you which mode is supported and which not:

using UnityEngine;
using System.Collections;

public class FocusModes : MonoBehaviour {
	
	private Rect mFocusNormalRect;
	private Rect mFocusMacroRect;
	private Rect mFocusAutoRect;
	private Rect mFocusInfRect;
	private Rect mFocusTriggerRect;
	
	
	private Rect mFocusLabelRect;
	private Rect mFocusDebugRect;
	
	private string mDebugMsg = "";
	private CameraDevice.FocusMode mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_NORMAL;
	
	// Use this for initialization
	void Start () {
		int w = Screen.width;
		int h = Screen.height;
		mFocusNormalRect = new Rect(w/2 - 200, h/2 - 25, 190, 50);
		mFocusMacroRect = new Rect(w/2, h/2 - 25, 190, 50);
		mFocusAutoRect = new Rect(w/2 - 200, h/2 + 25, 190, 50);
		mFocusInfRect = new Rect(w/2, h/2 + 25, 190, 50);
		mFocusTriggerRect = new Rect(w/2 - 200, h/2 + 75, 190, 50);
		
		mFocusLabelRect = new Rect(w/2 - 200, h/2 + 130, 350, 40);
		mFocusDebugRect = new Rect(w/2 - 200, h/2 + 160, 350, 40);
	}
	
	void OnGUI() {
		if (GUI.Button(mFocusNormalRect, "Focus Normal")) {
			if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL)) {
				mDebugMsg = "Focus Normal successfully set";
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_NORMAL;	
			}
		}
		if (GUI.Button(mFocusMacroRect, "Focus Macro")) {
			if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_MACRO)) {
				mDebugMsg = "Focus Macro successfully set";
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_MACRO;	
			}
			else {
				mDebugMsg = "Focus Macro not supported";
				CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL);
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_NORMAL;
			}
		}
		if (GUI.Button(mFocusInfRect, "Focus Infinity")) {
			if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_INFINITY)) {
				mDebugMsg = "Focus Inf. successfully set";
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_INFINITY;	
			}
			else {
				mDebugMsg = "Focus Infinity not supported";
				CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL);
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_NORMAL;
			}
		}
		if (GUI.Button(mFocusAutoRect, "Cont. AutoFocus")) {
			if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO)) {
				mDebugMsg = "AutoFocus successfully set";
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO;	
			}
			else {
				mDebugMsg = "Cont. AutoFocus not supported";
				CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL);
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_NORMAL;
			}
		}
		if (GUI.Button(mFocusTriggerRect, "Trigger Auto Focus")) {
			if (CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO)) {
				mDebugMsg = "TriggerAuto successfully set";
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO;	
			}
			else {
				mDebugMsg = "TriggerAuto not supported";
				CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL);
				mFocusMode = CameraDevice.FocusMode.FOCUS_MODE_NORMAL;
			}
		}
		
		GUI.skin.label.fontSize = 18;
		
		GUI.Label(mFocusLabelRect, mFocusMode.ToString());
		GUI.Label(mFocusDebugRect, mDebugMsg);
	}
}

 

Frame Marker Camera Focus

August 29, 2013 - 8:47am #2

Have you tried with the ImageTargetsMenu script of the ImageTargets sample ?

This allows you to enable Autofocus if supported, or to try and use the TRIGGER_AUTOFOCUS mode, which triggers an autofocus event on demand (for instance, whenever you tap on the screen, as shown in the example).

This should be consistent regardless that you use ImageTargets or FrameMarkers.

 

 

Log in or register to post comments