hi. first, i'm sorry about my english. i'm trying to make a program - using vuforia and webrtc in unity for android(like vuforia-chalk). i can another device connect and video,audio call(from webRTC), but if i import vuforia, i can't connection other device. because vuforia occupies the camera first, so webRTC can not access it. So, i'm trying to send camera view(or Texture? or byte array? i don't know it is corrrect ) to webRTC or vuforia. here comes the maddness : 1. how do i camera access at the same time from two library(vuforia and webrtc) 1.1. if i can't, how can i access vuforia camera? 1.2. otherwise, how can i send another video data byte array from webrtc to vuforia? i'm so sorry because I don't think my intentions are properly included and my english is so bad... thanks to read my question. Ki Deok
Hello @Kideokk, This cannot be done AFAIK. For most devices the camera is a singleton, so only one process can access at a time. Vuforia provides APIs to control the camera, so perhaps there is an option for you to disable the camera while Vuforia is running to make it available to another process: https://library.vuforia.com/content...rence/unity/classVuforia_1_1CameraDevice.html Vuforia 7.2 SDK does not allow camera frames from an external camera to be injected. This is a feature currently being evaluated for productization. Thanks, Vuforia Engine Support
thank you answer for my question. and i read your link, i have questions. i will trying send from vuforia camera data (using CameraDevice Class - GetCameraImage,and translate byte data) to WebRTC. (i don't know it is available). first - if i get vuforia camera data and send to WebRTC, 3D object is included? second - after i will creat AR Pen in UWP environment, have you any reference?(like vuforia - chalk)
Hello @Kideokk, No. These are the raw camera frames, as provided to Vuforia, before anything is rendered. Unlike the Vuforia SDK, there currently are no sample apps that demonstrate use cases similar to Vuforia Chalk. This is a standalone product (and app) that we sell. Thanks, Vuforia Engine Support
so, i tried screen capture, it is included 3D object. here is my screen capture code Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using System.IO; public class ScreenCapture : MonoBehaviour { // 4k = 3840 x 2160 1080p = 1920 x 1080 public int captureWidth = 1920; public int captureHeight = 1080; // optional game object to hide during screenshots (usually your scene canvas hud) public GameObject hideGameObject; // optimize for many screenshots will not destroy any objects so future screenshots will be fast public bool optimizeForManyScreenshots = true; // configure with raw, jpg, png, or ppm (simple raw format) public enum Format { RAW, JPG, PNG, PPM }; public Format format = Format.PPM; // folder to write output (defaults to data path) public string folder; // private vars for screenshot private Rect rect; private RenderTexture renderTexture; private Texture2D screenShot; private int counter = 0; // image # // commands private bool captureScreenshot = false; private bool captureVideo = false; // create a unique filename using a one-up variable private string UniqueFilename(int width, int height) { // if folder not specified by now use a good default if (folder == null || folder.Length == 0) { folder = Application.dataPath; if (Application.isEditor) { // put screenshots in folder above asset path so unity doesn't index the files var stringPath = folder + "/.."; folder = Path.GetFullPath(stringPath); } folder += "/screenshots"; // make sure directoroy exists System.IO.Directory.CreateDirectory(folder); // count number of files of specified format in folder string mask = string.Format("screen_{0}x{1}*.{2}", width, height, format.ToString().ToLower()); counter = Directory.GetFiles(folder, mask, SearchOption.TopDirectoryOnly).Length; } // use width, height, and counter for unique file name var filename = string.Format("{0}/screen_{1}x{2}_{3}.{4}", folder, width, height, counter, format.ToString().ToLower()); // up counter for next call ++counter; // return unique filename return filename; } public void CaptureScreenshot() { captureScreenshot = true; } void Update() { // check keyboard 'k' for one time screenshot capture and holding down 'v' for continious screenshots captureScreenshot |= Input.GetKeyDown("k"); captureVideo = Input.GetKey("v"); if (captureScreenshot || captureVideo) { captureScreenshot = false; // hide optional game object if set if (hideGameObject != null) hideGameObject.SetActive(false); // create screenshot objects if needed if (renderTexture == null) { // creates off-screen render texture that can rendered into rect = new Rect(0, 0, captureWidth, captureHeight); renderTexture = new RenderTexture(captureWidth, captureHeight, 24); screenShot = new Texture2D(captureWidth, captureHeight, TextureFormat.RGB24, false); } // get main camera and manually render scene into rt Camera camera = this.GetComponent<Camera>(); // NOTE: added because there was no reference to camera in original script; must add this script to Camera camera.targetTexture = renderTexture; camera.Render(); // read pixels will read from the currently active render texture so make our offscreen // render texture active and then read the pixels RenderTexture.active = renderTexture; screenShot.ReadPixels(rect, 0, 0); // reset active camera texture and render texture camera.targetTexture = null; RenderTexture.active = null; // get our unique filename string filename = UniqueFilename((int)rect.width, (int)rect.height); // pull in our file header/data bytes for the specified image format (has to be done from main thread) byte[] fileHeader = null; byte[] fileData = null; if (format == Format.RAW) { fileData = screenShot.GetRawTextureData(); } else if (format == Format.PNG) { fileData = screenShot.EncodeToPNG(); } else if (format == Format.JPG) { fileData = screenShot.EncodeToJPG(); } else // ppm { // create a file header for ppm formatted file string headerStr = string.Format("P6\n{0} {1}\n255\n", rect.width, rect.height); fileHeader = System.Text.Encoding.ASCII.GetBytes(headerStr); fileData = screenShot.GetRawTextureData(); } // create new thread to save the image to file (only operation that can be done in background) new System.Threading.Thread(() => { // create file and write optional header with image bytes var f = System.IO.File.Create(filename); if (fileHeader != null) f.Write(fileHeader, 0, fileHeader.Length); f.Write(fileData, 0, fileData.Length); f.Close(); Debug.Log(string.Format("Wrote screenshot {0} of size {1}", filename, fileData.Length)); }).Start(); // unhide optional game object if set if (hideGameObject != null) hideGameObject.SetActive(true); // cleanup if needed if (optimizeForManyScreenshots == false) { Destroy(renderTexture); renderTexture = null; screenShot = null; } } } } and i think that if i translate image to byte array and send to WebRTC camera, can't use it like? am I in the wrong direction? or Is there any other way? otherwise, it can't use(using two library : Vuforia and WebRTC)?