How to change the augmented reality camera in three.js? - camera

As the example, I try to set up the AR scene in three.js.
I use "jsartoolkit" to do that.
WebAR
I load a JSON model into the AR scene, and it does work.
Now I wonder how could I do to change the camera?
When I open the AR webpage, it always turn on the front device camera of my mobile phone.
I want to use the back device camera to show my WebAR scene.
How should I do?

Using cameraParam as a property name in your call to getUserMediaThreeScene may be incorrect.
Change:
cameraParam: 'Data/camera_para-iPhone 5 rear 640x480 1.0m.dat'
To:
video: { facingMode: { exact: "environment" }}
Reference: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia

Related

Camera Stacking in AR Game to Apply Overlay

I'm trying to create an AR game (similar to FPS), which requires camera stacking to allow for an AR base camera, as well as an overlay camera with overlays such as health points, bullet count etc. However, upon creating an empty GameObject and adding a camera component, I realise that I do not see the Render Type option in the inspector pane.
May I know what went wrong? Or how should I go about creating an AR game with a live AR camera feed with an overlay displaying health points etc?
Thanks and cheers!
enter image description here

How to create camera view in Objective-C

How can I just display a live feed of the rear camera in Objective-C? What do I need to add to my storyboard and what do I need to add to my ViewController? Any examples would be great.
You would need to use AVFoundation, specifically look at AVCaptureSession, AVCaptureDeviceInput, which you can use in order to get access to the cameras and look into AVCaptureVideoPreviewLayer which will allow you to draw the camera input to the screen
EDIT :
There's a step by step tutorial in Obj-C about it :
https://www.appcoda.com/ios-programming-camera-iphone-app/

How to capture App Screen as Video with Audio in Mac OSX?

I am writing a MacOS or OSX application where I need to record only the View of my application (Not the Whole display) with the Audio it emits.
Think it as a game app and I need to record the complete GamePlay View Of the Application.How should I go about doing this?
I am aware of "AVCaptureScreenInput" and, the example. But how to capture only the view of my application?
From the website you posted:
Note: By default, AVCaptureScreenInput captures the entire screen. You may set its cropRect property to limit the capture rectangle to a subsection of the screen.
Just set this property to the windows/views rect and you're done
Of course you need to update and restart the recording when the windows/views rect changes.
Read the document carefully, there is a comment, about the displays:
// If you're on a multi-display system and you want to capture a secondary display,
// you can call CGGetActiveDisplayList() to get the list of all active displays.
// For this example, we just specify the main display.
// To capture both a main and secondary display at the same time, use two active
// capture sessions, one for each display. On Mac OS X, AVCaptureMovieFileOutput
// only supports writing to a single video track.

Taking Control of ARCamera on Unity3D with Vuforia

The position and rotation of Vuforia's ARcam are determined by their algorithms to give the AR effect. I'd like to know how to do the following:
When some object is clicked the camera goes to some specific position (for that I need to somehow take control of the camera).
Also have to possibility to yield control of the camera back to Vuforia.
You'll want to use a second camera in this instance. Position the second camera at the AR Camera position, then adjust the depths to make the new camera the view that you see. Then you can tween its position to the predefined one you have.
Do the reverse to get control back to the AR Camera.

How to programmatically start front camera of iPad?

I would like to start front camera of the iPad when app starts.
How do I do it programmatically?
Please let me know.
First thing you need to do is to detect if your device has got front-facing camera. For that you need to iterate through the video devices.
Try this method of UIImagePickerController:
+ (BOOL)isCameraDeviceAvailable:(UIImagePickerControllerCameraDevice)cameraDevice
This is a class method and UIImagePickerControllerCameraDevice can take two values:
- UIImagePickerControllerCameraDeviceRear
- UIImagePickerControllerCameraDeviceFront
Example code:
if( [UIImagePickerController isCameraDeviceAvailable: UIImagePickerControllerCameraDeviceFront ])
{
// do something
}
Note that this is available for iOS 4.0 and later.
Also I am not sure if there is any API's to start the front-facing camera up front. The camera always seems to start in the same mode that the user left it the last time it was used. Maybe by design Apple did not expose any API's to change this. Maybe Apple wanted the users to make a call on this.
Nevertheless you can atleast detect the availability of Fron Camera & provide your feature.
If I understand your question correctly, all you have to do is open your Camera to be in Front Mode instead of Rear Mode, so write this inside the method where you call the picker for the first time:
picker.cameraDevice=UIImagePickerControllerCameraDeviceFront;
Hope this answers your question.