N
N
NRSDK
Search…
Access RGB Camera

Device Compatibility

Device Compatibility

The reliability of glasses' RGB Camera has been fully tested on the following Android phones:
  • Oneplus: 9 / 9pro
  • Samsung: Galaxy S10+ / Galaxy S21 / Galaxy S21 Ultra 5G / Galaxy S21 5G / Galaxy S21 5G / Galaxy S20 Ultra 5G / Galaxy S20+ 5G / Galaxy Note20 5G / Galaxy S21 5G / Galaxy Z Fold 3 5G / Galaxy S22
  • Sony: X1 iii
  • LG: Wing / V50s
  • Arrows: NX9
  • OPPO: Find X2 pro / Find X5 pro
Glasses' RGB camera can also work on Android phones besides the above. However, the compatibility is not guaranteed. For the full list, please refer to Device Compatibility.

Developer Guide

Import the NRSDK

Import NRSDKForUnity_1.8.0.unitypackage in the package.

Open the Sample Scene

In the Unity Project window, you can find the CameraCaptureDemo sample in: Assets > NRSDK >Demos > RGBCamera-Record.

Inspect the Sample Code

  • See CameraCaptureController.cs , located in Assets/NRSDK/Demos/RGBCamera/Scripts/CameraCaptureController.cs for an example on how to get the texture of RGB Camera.
1
public RawImage CaptureImage;
2
3
private void Start()
4
{
5
RGBCamTexture = new NRRGBCamTexture();
6
CaptureImage.texture = RGBCamTexture.GetTexture();
7
RGBCamTexture.Play();
8
}
Copied!
  • See VideoCapture2LocalExample.cs, located in Assets/NRSDK/Demos/Record/Scriptsfor an example on how to implement video capture
1
// A video Capture Example
2
public class VideoCapture2LocalExample : MonoBehaviour
3
{
4
/// <summary> The previewer. </summary>
5
public NRPreviewer Previewer;
6
public VideoRecordConfigPanel m_ConfigPanel;
7
8
/// <summary> Save the video to Application.persistentDataPath. </summary>
9
/// <value> The full pathname of the video save file. </value>
10
public string VideoSavePath
11
{
12
get
13
{
14
string timeStamp = Time.time.ToString().Replace(".", "").Replace(":", "");
15
string filename = string.Format("Nreal_Record_{0}.mp4", timeStamp);
16
return Path.Combine(Application.persistentDataPath, filename);
17
}
18
}
19
20
/// <summary> The video capture. </summary>
21
NRVideoCapture m_VideoCapture = null;
22
23
/// <summary> Starts this object. </summary>
24
void Start()
25
{
26
CreateVideoCaptureTest();
27
}
28
29
/// <summary> Tests create video capture. </summary>
30
void CreateVideoCaptureTest()
31
{
32
NRVideoCapture.CreateAsync(false, delegate (NRVideoCapture videoCapture)
33
{
34
NRDebugger.Info("Created VideoCapture Instance!");
35
if (videoCapture != null)
36
{
37
m_VideoCapture = videoCapture;
38
}
39
else
40
{
41
NRDebugger.Error("Failed to create VideoCapture Instance!");
42
}
43
});
44
}
45
46
/// <summary> Starts video capture. </summary>
47
public void StartVideoCapture()
48
{
49
if (m_VideoCapture != null)
50
{
51
CameraParameters cameraParameters = new CameraParameters();
52
if (m_ConfigPanel == null)
53
{
54
Resolution cameraResolution = NRVideoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();
55
cameraParameters.hologramOpacity = 0.0f;
56
cameraParameters.frameRate = cameraResolution.refreshRate;
57
cameraParameters.cameraResolutionWidth = cameraResolution.width;
58
cameraParameters.cameraResolutionHeight = cameraResolution.height;
59
cameraParameters.pixelFormat = CapturePixelFormat.BGRA32;
60
// Set the blend mode.
61
cameraParameters.blendMode = BlendMode.Blend;
62
// Set audio state, audio record needs the permission of "android.permission.RECORD_AUDIO",
63
// Add it to your "AndroidManifest.xml" file in "Assets/Plugin".
64
cameraParameters.audioState = NRVideoCapture.AudioState.MicAudio;
65
}
66
else
67
{
68
cameraParameters = m_ConfigPanel.GetRecordConfigration();
69
}
70
71
m_VideoCapture.StartVideoModeAsync(cameraParameters, OnStartedVideoCaptureMode);
72
}
73
}
74
75
/// <summary> Stops video capture. </summary>
76
public void StopVideoCapture()
77
{
78
if (m_VideoCapture == null)
79
{
80
return;
81
}
82
83
NRDebugger.Info("Stop Video Capture!");
84
m_VideoCapture.StopRecordingAsync(OnStoppedRecordingVideo);
85
Previewer.SetData(m_VideoCapture.PreviewTexture, false);
86
}
87
88
/// <summary> Executes the 'started video capture mode' action. </summary>
89
/// <param name="result"> The result.</param>
90
void OnStartedVideoCaptureMode(NRVideoCapture.VideoCaptureResult result)
91
{
92
if (!result.success)
93
{
94
NRDebugger.Info("Started Video Capture Mode faild!");
95
return;
96
}
97
98
NRDebugger.Info("Started Video Capture Mode!");
99
m_VideoCapture.StartRecordingAsync(VideoSavePath, OnStartedRecordingVideo);
100
// Set preview texture.
101
Previewer.SetData(m_VideoCapture.PreviewTexture, true);
102
}
103
104
/// <summary> Executes the 'started recording video' action. </summary>
105
/// <param name="result"> The result.</param>
106
void OnStartedRecordingVideo(NRVideoCapture.VideoCaptureResult result)
107
{
108
if (!result.success)
109
{
110
NRDebugger.Info("Started Recording Video Faild!");
111
return;
112
}
113
114
NRDebugger.Info("Started Recording Video!");
115
if (m_ConfigPanel != null && m_ConfigPanel.UseGreenBackground)
116
{
117
// Set green background color.
118
m_VideoCapture.GetContext().GetBehaviour().SetBackGroundColor(Color.green);
119
}
120
}
121
122
/// <summary> Executes the 'stopped recording video' action. </summary>
123
/// <param name="result"> The result.</param>
124
void OnStoppedRecordingVideo(NRVideoCapture.VideoCaptureResult result)
125
{
126
if (!result.success)
127
{
128
NRDebugger.Info("Stopped Recording Video Faild!");
129
return;
130
}
131
132
NRDebugger.Info("Stopped Recording Video!");
133
m_VideoCapture.StopVideoModeAsync(OnStoppedVideoCaptureMode);
134
}
135
136
/// <summary> Executes the 'stopped video capture mode' action. </summary>
137
/// <param name="result"> The result.</param>
138
void OnStoppedVideoCaptureMode(NRVideoCapture.VideoCaptureResult result)
139
{
140
NRDebugger.Info("Stopped Video Capture Mode!");
141
}
142
}
Copied!

Build and Run the Sample App

  • Audio record needs the permission of “android.permission.RECORD_AUDIO”, Add it to your “AndroidManifest.xml” file in “Assets/Plugin”.
  • The Previewer is used to preview live images in real time, for debugging purposes. Click the APP key of the controller to show or hide it.
  • Click the Start button to start video capture.
  • Click the Stop button to stop video capture. It will save the video file to “Application.persistentDataPath” path.