Skip to content

Commit e567884

Browse files
committedApr 16, 2018
v0.0.2
Added the function to convert the camera frame image to the correct direction to WebCamTextureOnlyExample. Updated OpenCVForUnity version to 2.2.8.
1 parent 40b07e2 commit e567884

File tree

10 files changed

+2457
-2272
lines changed

10 files changed

+2457
-2272
lines changed
 

Diff for: ‎Assets/NatCamWithOpenCVForUnityExample/NatCamPreviewOnlyExample/NatCamPreviewOnlyExample.cs

+375-357
Large diffs are not rendered by default.

Diff for: ‎Assets/NatCamWithOpenCVForUnityExample/NatCamPreviewToMatExample/NatCamPreviewToMatExample.cs

+401-388
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,119 @@
1-
using UnityEngine;
2-
using System.Collections;
3-
using UnityEngine.UI;
4-
5-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
6-
using UnityEngine.SceneManagement;
7-
#endif
8-
9-
namespace NatCamWithOpenCVForUnityExample
10-
{
11-
public class NatCamWithOpenCVForUnityExample : MonoBehaviour
12-
{
13-
public Text versionInfo;
14-
public ScrollRect scrollRect;
15-
static float verticalNormalizedPosition = 1f;
16-
17-
// Use this for initialization
18-
void Start ()
19-
{
20-
versionInfo.text = OpenCVForUnity.Core.NATIVE_LIBRARY_NAME + " " + OpenCVForUnity.Utils.getVersion () + " (" + OpenCVForUnity.Core.VERSION + ")";
21-
versionInfo.text += " / UnityEditor " + Application.unityVersion;
22-
versionInfo.text += " / ";
23-
24-
#if UNITY_EDITOR
25-
versionInfo.text += "Editor";
26-
#elif UNITY_STANDALONE_WIN
27-
versionInfo.text += "Windows";
28-
#elif UNITY_STANDALONE_OSX
29-
versionInfo.text += "Mac OSX";
30-
#elif UNITY_STANDALONE_LINUX
31-
versionInfo.text += "Linux";
32-
#elif UNITY_ANDROID
33-
versionInfo.text += "Android";
34-
#elif UNITY_IOS
35-
versionInfo.text += "iOS";
36-
#elif UNITY_WSA
37-
versionInfo.text += "WSA";
38-
#elif UNITY_WEBGL
39-
versionInfo.text += "WebGL";
40-
#endif
41-
versionInfo.text += " ";
42-
#if ENABLE_MONO
43-
versionInfo.text += "Mono";
44-
#elif ENABLE_IL2CPP
45-
versionInfo.text += "IL2CPP";
46-
#elif ENABLE_DOTNET
47-
versionInfo.text += ".NET";
48-
#endif
49-
50-
scrollRect.verticalNormalizedPosition = verticalNormalizedPosition;
51-
}
52-
53-
// Update is called once per frame
54-
void Update ()
55-
{
56-
57-
}
58-
59-
public void OnScrollRectValueChanged ()
60-
{
61-
verticalNormalizedPosition = scrollRect.verticalNormalizedPosition;
62-
}
63-
64-
65-
public void OnShowSystemInfoButtonClick ()
66-
{
67-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
68-
SceneManager.LoadScene ("ShowSystemInfo");
69-
#else
70-
Application.LoadLevel ("ShowSystemInfo");
71-
#endif
72-
}
73-
74-
public void OnShowLicenseButtonClick ()
75-
{
76-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
77-
SceneManager.LoadScene ("ShowLicense");
78-
#else
79-
Application.LoadLevel ("ShowLicense");
80-
#endif
81-
}
82-
83-
public void OnNatCamPreviewOnlyExampleButtonClick ()
84-
{
85-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
86-
SceneManager.LoadScene ("NatCamPreviewOnlyExample");
87-
#else
88-
Application.LoadLevel ("NatCamPreviewOnlyExample");
89-
#endif
90-
}
91-
92-
public void OnWebCamTextureOnlyExampleButtonClick ()
93-
{
94-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
95-
SceneManager.LoadScene ("WebCamTextureOnlyExample");
96-
#else
97-
Application.LoadLevel ("WebCamTextureOnlyExample");
98-
#endif
99-
}
100-
101-
public void OnNatCamPreviewToMatExampleButtonClick ()
102-
{
103-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
104-
SceneManager.LoadScene ("NatCamPreviewToMatExample");
105-
#else
106-
Application.LoadLevel ("NatCamPreviewToMatExample");
107-
#endif
108-
}
109-
110-
public void OnWebCamTextureToMatExampleButtonClick ()
111-
{
112-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
113-
SceneManager.LoadScene ("WebCamTextureToMatExample");
114-
#else
115-
Application.LoadLevel ("WebCamTextureToMatExample");
116-
#endif
117-
}
118-
}
119-
}
1+
using UnityEngine;
2+
using System.Collections;
3+
using UnityEngine.UI;
4+
5+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
6+
using UnityEngine.SceneManagement;
7+
#endif
8+
9+
namespace NatCamWithOpenCVForUnityExample
10+
{
11+
public class NatCamWithOpenCVForUnityExample : MonoBehaviour
12+
{
13+
public Text versionInfo;
14+
public ScrollRect scrollRect;
15+
static float verticalNormalizedPosition = 1f;
16+
17+
// Use this for initialization
18+
void Start ()
19+
{
20+
versionInfo.text = OpenCVForUnity.Core.NATIVE_LIBRARY_NAME + " " + OpenCVForUnity.Utils.getVersion () + " (" + OpenCVForUnity.Core.VERSION + ")";
21+
versionInfo.text += " / UnityEditor " + Application.unityVersion;
22+
versionInfo.text += " / ";
23+
24+
#if UNITY_EDITOR
25+
versionInfo.text += "Editor";
26+
#elif UNITY_STANDALONE_WIN
27+
versionInfo.text += "Windows";
28+
#elif UNITY_STANDALONE_OSX
29+
versionInfo.text += "Mac OSX";
30+
#elif UNITY_STANDALONE_LINUX
31+
versionInfo.text += "Linux";
32+
#elif UNITY_ANDROID
33+
versionInfo.text += "Android";
34+
#elif UNITY_IOS
35+
versionInfo.text += "iOS";
36+
#elif UNITY_WSA
37+
versionInfo.text += "WSA";
38+
#elif UNITY_WEBGL
39+
versionInfo.text += "WebGL";
40+
#endif
41+
versionInfo.text += " ";
42+
#if ENABLE_MONO
43+
versionInfo.text += "Mono";
44+
#elif ENABLE_IL2CPP
45+
versionInfo.text += "IL2CPP";
46+
#elif ENABLE_DOTNET
47+
versionInfo.text += ".NET";
48+
#endif
49+
50+
scrollRect.verticalNormalizedPosition = verticalNormalizedPosition;
51+
}
52+
53+
// Update is called once per frame
54+
void Update ()
55+
{
56+
57+
}
58+
59+
public void OnScrollRectValueChanged ()
60+
{
61+
verticalNormalizedPosition = scrollRect.verticalNormalizedPosition;
62+
}
63+
64+
65+
public void OnShowSystemInfoButtonClick ()
66+
{
67+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
68+
SceneManager.LoadScene ("ShowSystemInfo");
69+
#else
70+
Application.LoadLevel ("ShowSystemInfo");
71+
#endif
72+
}
73+
74+
public void OnShowLicenseButtonClick ()
75+
{
76+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
77+
SceneManager.LoadScene ("ShowLicense");
78+
#else
79+
Application.LoadLevel ("ShowLicense");
80+
#endif
81+
}
82+
83+
public void OnNatCamPreviewOnlyExampleButtonClick ()
84+
{
85+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
86+
SceneManager.LoadScene ("NatCamPreviewOnlyExample");
87+
#else
88+
Application.LoadLevel ("NatCamPreviewOnlyExample");
89+
#endif
90+
}
91+
92+
public void OnWebCamTextureOnlyExampleButtonClick ()
93+
{
94+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
95+
SceneManager.LoadScene ("WebCamTextureOnlyExample");
96+
#else
97+
Application.LoadLevel ("WebCamTextureOnlyExample");
98+
#endif
99+
}
100+
101+
public void OnNatCamPreviewToMatExampleButtonClick ()
102+
{
103+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
104+
SceneManager.LoadScene ("NatCamPreviewToMatExample");
105+
#else
106+
Application.LoadLevel ("NatCamPreviewToMatExample");
107+
#endif
108+
}
109+
110+
public void OnWebCamTextureToMatExampleButtonClick ()
111+
{
112+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
113+
SceneManager.LoadScene ("WebCamTextureToMatExample");
114+
#else
115+
Application.LoadLevel ("WebCamTextureToMatExample");
116+
#endif
117+
}
118+
}
119+
}

Diff for: ‎Assets/NatCamWithOpenCVForUnityExample/NatCamWithOpenCVForUnityExample.unity

+3-22
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,6 @@ GameObject:
811811
- component: {fileID: 743992500}
812812
- component: {fileID: 743992499}
813813
- component: {fileID: 743992498}
814-
- component: {fileID: 743992497}
815814
m_Layer: 5
816815
m_Name: ShowSystemInfoButton
817816
m_TagString: Untagged
@@ -831,31 +830,13 @@ RectTransform:
831830
m_Children:
832831
- {fileID: 304459245}
833832
m_Father: {fileID: 1810133384}
834-
m_RootOrder: 0
833+
m_RootOrder: 1
835834
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
836835
m_AnchorMin: {x: 1, y: 1}
837836
m_AnchorMax: {x: 1, y: 1}
838837
m_AnchoredPosition: {x: -9.999878, y: -9.999939}
839838
m_SizeDelta: {x: 100, y: 50}
840839
m_Pivot: {x: 1, y: 1}
841-
--- !u!114 &743992497
842-
MonoBehaviour:
843-
m_ObjectHideFlags: 0
844-
m_PrefabParentObject: {fileID: 0}
845-
m_PrefabInternal: {fileID: 0}
846-
m_GameObject: {fileID: 743992495}
847-
m_Enabled: 0
848-
m_EditorHideFlags: 0
849-
m_Script: {fileID: 1679637790, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
850-
m_Name:
851-
m_EditorClassIdentifier:
852-
m_IgnoreLayout: 1
853-
m_MinWidth: 780
854-
m_MinHeight: 60
855-
m_PreferredWidth: -1
856-
m_PreferredHeight: -1
857-
m_FlexibleWidth: -1
858-
m_FlexibleHeight: -1
859840
--- !u!114 &743992498
860841
MonoBehaviour:
861842
m_ObjectHideFlags: 0
@@ -2294,7 +2275,7 @@ RectTransform:
22942275
- {fileID: 595830808}
22952276
- {fileID: 398629471}
22962277
m_Father: {fileID: 1810133384}
2297-
m_RootOrder: 1
2278+
m_RootOrder: 0
22982279
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
22992280
m_AnchorMin: {x: 0, y: 0}
23002281
m_AnchorMax: {x: 1, y: 1}
@@ -2408,8 +2389,8 @@ RectTransform:
24082389
m_LocalPosition: {x: 0, y: 0, z: 0}
24092390
m_LocalScale: {x: 0, y: 0, z: 0}
24102391
m_Children:
2411-
- {fileID: 743992496}
24122392
- {fileID: 1800755751}
2393+
- {fileID: 743992496}
24132394
m_Father: {fileID: 0}
24142395
m_RootOrder: 2
24152396
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,169 @@
1-
using UnityEngine;
2-
using System.Collections;
3-
using System.Collections.Generic;
4-
5-
namespace NatCamWithOpenCVForUnityExample
6-
{
7-
public class FpsMonitor : MonoBehaviour
8-
{
9-
int tick = 0;
10-
float elapsed = 0;
11-
float fps = 0;
12-
13-
public enum Alignment
14-
{
15-
LeftTop,
16-
RightTop,
17-
LeftBottom,
18-
RightBottom,
19-
}
20-
21-
public Alignment alignment = Alignment.RightTop;
22-
23-
const float GUI_WIDTH = 75f;
24-
const float GUI_HEIGHT = 30f;
25-
const float MARGIN_X = 10f;
26-
const float MARGIN_Y = 10f;
27-
const float INNER_X = 8f;
28-
const float INNER_Y = 5f;
29-
const float GUI_CONSOLE_HEIGHT = 50f;
30-
31-
public Vector2 offset = new Vector2(MARGIN_X, MARGIN_Y);
32-
public bool boxVisible = true;
33-
public float boxWidth = GUI_WIDTH;
34-
public float boxHeight = GUI_HEIGHT;
35-
public Vector2 padding = new Vector2(INNER_X, INNER_Y);
36-
public float consoleHeight = GUI_CONSOLE_HEIGHT;
37-
38-
GUIStyle console_labelStyle;
39-
40-
float x, y;
41-
Rect outer;
42-
Rect inner;
43-
44-
float console_x, console_y;
45-
Rect console_outer;
46-
Rect console_inner;
47-
48-
int oldScrWidth;
49-
int oldScrHeight;
50-
51-
Dictionary<string, string> outputDict = new Dictionary<string, string> ();
52-
public string consoleText;
53-
54-
// Use this for initialization
55-
void Start () {
56-
console_labelStyle = new GUIStyle ();
57-
console_labelStyle.fontSize = 32;
58-
console_labelStyle.fontStyle = FontStyle.Normal;
59-
console_labelStyle.wordWrap = true;
60-
console_labelStyle.normal.textColor = Color.white;
61-
62-
oldScrWidth = Screen.width;
63-
oldScrHeight = Screen.height;
64-
LocateGUI();
65-
}
66-
67-
// Update is called once per frame
68-
void Update () {
69-
tick++;
70-
elapsed += Time.deltaTime;
71-
if (elapsed >= 1f) {
72-
fps = tick / elapsed;
73-
tick = 0;
74-
elapsed = 0;
75-
}
76-
}
77-
78-
void OnGUI () {
79-
if (oldScrWidth != Screen.width || oldScrHeight != Screen.height) {
80-
LocateGUI();
81-
}
82-
oldScrWidth = Screen.width;
83-
oldScrHeight = Screen.height;
84-
85-
if (boxVisible) {
86-
GUI.Box(outer, "");
87-
}
88-
89-
GUILayout.BeginArea(inner);
90-
{
91-
GUILayout.BeginVertical();
92-
GUILayout.Label("fps : " + fps.ToString("F1"));
93-
foreach (KeyValuePair<string, string> pair in outputDict) {
94-
GUILayout.Label(pair.Key + " : " + pair.Value);
95-
}
96-
GUILayout.EndVertical();
97-
}
98-
GUILayout.EndArea ();
99-
100-
if (!string.IsNullOrEmpty(consoleText)) {
101-
if (boxVisible) {
102-
GUI.Box (console_outer, "");
103-
}
104-
105-
GUILayout.BeginArea (console_inner);
106-
{
107-
GUILayout.BeginVertical ();
108-
GUILayout.Label (consoleText, console_labelStyle);
109-
GUILayout.EndVertical ();
110-
}
111-
GUILayout.EndArea ();
112-
}
113-
}
114-
115-
public void Add (string key, string value) {
116-
if (outputDict.ContainsKey (key)) {
117-
outputDict [key] = value;
118-
} else {
119-
outputDict.Add (key, value);
120-
}
121-
}
122-
123-
public void Remove (string key) {
124-
outputDict.Remove (key);
125-
}
126-
127-
public void Clear () {
128-
outputDict.Clear ();
129-
}
130-
131-
public void LocateGUI() {
132-
x = GetAlignedX(alignment, boxWidth);
133-
y = GetAlignedY(alignment, boxHeight);
134-
outer = new Rect(x, y, boxWidth, boxHeight);
135-
inner = new Rect(x + padding.x, y + padding.y, boxWidth, boxHeight);
136-
137-
console_x = GetAlignedX(Alignment.LeftBottom, Screen.width);
138-
console_y = GetAlignedY(Alignment.LeftBottom, consoleHeight);
139-
console_outer = new Rect(console_x, console_y, Screen.width - offset.x*2, consoleHeight);
140-
console_inner = new Rect(console_x + padding.x, console_y + padding.y, Screen.width - offset.x*2 - padding.x, consoleHeight);
141-
}
142-
143-
float GetAlignedX(Alignment anchor, float w) {
144-
switch (anchor) {
145-
default:
146-
case Alignment.LeftTop:
147-
case Alignment.LeftBottom:
148-
return offset.x;
149-
150-
case Alignment.RightTop:
151-
case Alignment.RightBottom:
152-
return Screen.width - w - offset.x;
153-
}
154-
}
155-
156-
float GetAlignedY(Alignment anchor, float h) {
157-
switch (anchor) {
158-
default:
159-
case Alignment.LeftTop:
160-
case Alignment.RightTop:
161-
return offset.y;
162-
163-
case Alignment.LeftBottom:
164-
case Alignment.RightBottom:
165-
return Screen.height - h - offset.y;
166-
}
167-
}
168-
}
1+
using UnityEngine;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
5+
namespace NatCamWithOpenCVForUnityExample
6+
{
7+
public class FpsMonitor : MonoBehaviour
8+
{
9+
int tick = 0;
10+
float elapsed = 0;
11+
float fps = 0;
12+
13+
public enum Alignment
14+
{
15+
LeftTop,
16+
RightTop,
17+
LeftBottom,
18+
RightBottom,
19+
}
20+
21+
public Alignment alignment = Alignment.RightTop;
22+
23+
const float GUI_WIDTH = 75f;
24+
const float GUI_HEIGHT = 30f;
25+
const float MARGIN_X = 10f;
26+
const float MARGIN_Y = 10f;
27+
const float INNER_X = 8f;
28+
const float INNER_Y = 5f;
29+
const float GUI_CONSOLE_HEIGHT = 50f;
30+
31+
public Vector2 offset = new Vector2(MARGIN_X, MARGIN_Y);
32+
public bool boxVisible = true;
33+
public float boxWidth = GUI_WIDTH;
34+
public float boxHeight = GUI_HEIGHT;
35+
public Vector2 padding = new Vector2(INNER_X, INNER_Y);
36+
public float consoleHeight = GUI_CONSOLE_HEIGHT;
37+
38+
GUIStyle console_labelStyle;
39+
40+
float x, y;
41+
Rect outer;
42+
Rect inner;
43+
44+
float console_x, console_y;
45+
Rect console_outer;
46+
Rect console_inner;
47+
48+
int oldScrWidth;
49+
int oldScrHeight;
50+
51+
Dictionary<string, string> outputDict = new Dictionary<string, string> ();
52+
public string consoleText;
53+
54+
// Use this for initialization
55+
void Start () {
56+
console_labelStyle = new GUIStyle ();
57+
console_labelStyle.fontSize = 32;
58+
console_labelStyle.fontStyle = FontStyle.Normal;
59+
console_labelStyle.wordWrap = true;
60+
console_labelStyle.normal.textColor = Color.white;
61+
62+
oldScrWidth = Screen.width;
63+
oldScrHeight = Screen.height;
64+
LocateGUI();
65+
}
66+
67+
// Update is called once per frame
68+
void Update () {
69+
tick++;
70+
elapsed += Time.deltaTime;
71+
if (elapsed >= 1f) {
72+
fps = tick / elapsed;
73+
tick = 0;
74+
elapsed = 0;
75+
}
76+
}
77+
78+
void OnGUI () {
79+
if (oldScrWidth != Screen.width || oldScrHeight != Screen.height) {
80+
LocateGUI();
81+
}
82+
oldScrWidth = Screen.width;
83+
oldScrHeight = Screen.height;
84+
85+
if (boxVisible) {
86+
GUI.Box(outer, "");
87+
}
88+
89+
GUILayout.BeginArea(inner);
90+
{
91+
GUILayout.BeginVertical();
92+
GUILayout.Label("fps : " + fps.ToString("F1"));
93+
foreach (KeyValuePair<string, string> pair in outputDict) {
94+
GUILayout.Label(pair.Key + " : " + pair.Value);
95+
}
96+
GUILayout.EndVertical();
97+
}
98+
GUILayout.EndArea ();
99+
100+
if (!string.IsNullOrEmpty(consoleText)) {
101+
if (boxVisible) {
102+
GUI.Box (console_outer, "");
103+
}
104+
105+
GUILayout.BeginArea (console_inner);
106+
{
107+
GUILayout.BeginVertical ();
108+
GUILayout.Label (consoleText, console_labelStyle);
109+
GUILayout.EndVertical ();
110+
}
111+
GUILayout.EndArea ();
112+
}
113+
}
114+
115+
public void Add (string key, string value) {
116+
if (outputDict.ContainsKey (key)) {
117+
outputDict [key] = value;
118+
} else {
119+
outputDict.Add (key, value);
120+
}
121+
}
122+
123+
public void Remove (string key) {
124+
outputDict.Remove (key);
125+
}
126+
127+
public void Clear () {
128+
outputDict.Clear ();
129+
}
130+
131+
public void LocateGUI() {
132+
x = GetAlignedX(alignment, boxWidth);
133+
y = GetAlignedY(alignment, boxHeight);
134+
outer = new Rect(x, y, boxWidth, boxHeight);
135+
inner = new Rect(x + padding.x, y + padding.y, boxWidth, boxHeight);
136+
137+
console_x = GetAlignedX(Alignment.LeftBottom, Screen.width);
138+
console_y = GetAlignedY(Alignment.LeftBottom, consoleHeight);
139+
console_outer = new Rect(console_x, console_y, Screen.width - offset.x*2, consoleHeight);
140+
console_inner = new Rect(console_x + padding.x, console_y + padding.y, Screen.width - offset.x*2 - padding.x, consoleHeight);
141+
}
142+
143+
float GetAlignedX(Alignment anchor, float w) {
144+
switch (anchor) {
145+
default:
146+
case Alignment.LeftTop:
147+
case Alignment.LeftBottom:
148+
return offset.x;
149+
150+
case Alignment.RightTop:
151+
case Alignment.RightBottom:
152+
return Screen.width - w - offset.x;
153+
}
154+
}
155+
156+
float GetAlignedY(Alignment anchor, float h) {
157+
switch (anchor) {
158+
default:
159+
case Alignment.LeftTop:
160+
case Alignment.RightTop:
161+
return offset.y;
162+
163+
case Alignment.LeftBottom:
164+
case Alignment.RightBottom:
165+
return Screen.height - h - offset.y;
166+
}
167+
}
168+
}
169169
}
+33-33
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
using UnityEngine;
2-
using System.Collections;
3-
4-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
5-
using UnityEngine.SceneManagement;
6-
#endif
7-
8-
namespace NatCamWithOpenCVForUnityExample
9-
{
10-
public class ShowLicense : MonoBehaviour
11-
{
12-
// Use this for initialization
13-
void Start()
14-
{
15-
16-
}
17-
18-
// Update is called once per frame
19-
void Update()
20-
{
21-
22-
}
23-
24-
public void OnBackButtonClick()
25-
{
26-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
27-
SceneManager.LoadScene ("NatCamWithOpenCVForUnityExample");
28-
#else
29-
Application.LoadLevel("NatCamWithOpenCVForUnityExample");
30-
#endif
31-
}
32-
}
33-
}
1+
using UnityEngine;
2+
using System.Collections;
3+
4+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
5+
using UnityEngine.SceneManagement;
6+
#endif
7+
8+
namespace NatCamWithOpenCVForUnityExample
9+
{
10+
public class ShowLicense : MonoBehaviour
11+
{
12+
// Use this for initialization
13+
void Start()
14+
{
15+
16+
}
17+
18+
// Update is called once per frame
19+
void Update()
20+
{
21+
22+
}
23+
24+
public void OnBackButtonClick()
25+
{
26+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
27+
SceneManager.LoadScene ("NatCamWithOpenCVForUnityExample");
28+
#else
29+
Application.LoadLevel("NatCamWithOpenCVForUnityExample");
30+
#endif
31+
}
32+
}
33+
}
+130-130
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,131 @@
1-
using UnityEngine;
2-
using System.Collections;
3-
using System.Collections.Generic;
4-
using UnityEngine.UI;
5-
6-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
7-
using UnityEngine.SceneManagement;
8-
#endif
9-
10-
namespace NatCamWithOpenCVForUnityExample
11-
{
12-
public class ShowSystemInfo : MonoBehaviour
13-
{
14-
public Text systemInfoText;
15-
public InputField systemInfoInputField;
16-
Dictionary<string, string> dicSystemInfo;
17-
18-
// Use this for initialization
19-
void Start ()
20-
{
21-
dicSystemInfo = GetSystemInfo ();
22-
23-
systemInfoText.text = systemInfoInputField.text = "### System Info ###" + "\n";
24-
Debug.Log("### System Info ###");
25-
26-
foreach (string key in dicSystemInfo.Keys)
27-
{
28-
systemInfoText.text = systemInfoInputField.text += key + " = " + dicSystemInfo [key] + "\n";
29-
Debug.Log(key + "=" + dicSystemInfo[key]);
30-
}
31-
32-
systemInfoText.text = systemInfoInputField.text += "###################" + "\n";
33-
Debug.Log("###################");
34-
}
35-
36-
// Update is called once per frame
37-
void Update ()
38-
{
39-
40-
}
41-
42-
public Dictionary<string, string> GetSystemInfo()
43-
{
44-
Dictionary<string, string> dicSystemInfo = new Dictionary<string, string> ();
45-
46-
dicSystemInfo.Add("OpenCVForUnity version", OpenCVForUnity.Core.NATIVE_LIBRARY_NAME + " " + OpenCVForUnity.Utils.getVersion () + " (" + OpenCVForUnity.Core.VERSION + ")");
47-
dicSystemInfo.Add("Build Unity version", Application.unityVersion);
48-
49-
#if UNITY_EDITOR
50-
dicSystemInfo.Add("Build target", "Editor");
51-
#elif UNITY_STANDALONE_WIN
52-
dicSystemInfo.Add("Build target", "Windows");
53-
#elif UNITY_STANDALONE_OSX
54-
dicSystemInfo.Add("Build target", "Mac OSX");
55-
#elif UNITY_STANDALONE_LINUX
56-
dicSystemInfo.Add("Build target", "Linux");
57-
#elif UNITY_ANDROID
58-
dicSystemInfo.Add("Build target", "Android");
59-
#elif UNITY_IOS
60-
dicSystemInfo.Add("Build target", "iOS");
61-
#elif UNITY_WSA
62-
dicSystemInfo.Add("Build target", "WSA");
63-
#elif UNITY_WEBGL
64-
dicSystemInfo.Add("Build target", "WebGL");
65-
#else
66-
dicSystemInfo.Add("Build target", "");
67-
#endif
68-
69-
#if ENABLE_MONO
70-
dicSystemInfo.Add("Scripting backend", "Mono");
71-
#elif ENABLE_IL2CPP
72-
dicSystemInfo.Add("Scripting backend", "IL2CPP");
73-
#elif ENABLE_DOTNET
74-
dicSystemInfo.Add("Scripting backend", ".NET");
75-
#else
76-
dicSystemInfo.Add("Scripting backend", "");
77-
#endif
78-
79-
dicSystemInfo.Add("operatingSystem", SystemInfo.operatingSystem);
80-
81-
#if UNITY_IOS
82-
#if UNITY_5_4_OR_NEWER
83-
dicSystemInfo.Add("iPhone.generation", UnityEngine.iOS.Device.generation.ToString());
84-
#else
85-
dicSystemInfo.Add("iPhone.generation", UnityEngine.iPhone.generation.ToString());
86-
#endif
87-
#else
88-
dicSystemInfo.Add ("iPhone.generation", "");
89-
#endif
90-
91-
//dicSystemInfo.Add("deviceUniqueIdentifier", SystemInfo.deviceUniqueIdentifier);
92-
dicSystemInfo.Add("deviceModel", SystemInfo.deviceModel);
93-
dicSystemInfo.Add("deviceName", SystemInfo.deviceName);
94-
dicSystemInfo.Add("deviceType", SystemInfo.deviceType.ToString());
95-
dicSystemInfo.Add("graphicsDeviceName", SystemInfo.graphicsDeviceName);
96-
dicSystemInfo.Add("graphicsDeviceVendor", SystemInfo.graphicsDeviceVendor);
97-
dicSystemInfo.Add("processorType", SystemInfo.processorType);
98-
dicSystemInfo.Add("graphicsMemorySize", SystemInfo.graphicsMemorySize.ToString());
99-
dicSystemInfo.Add("systemMemorySize", SystemInfo.systemMemorySize.ToString());
100-
101-
dicSystemInfo.Add("graphicsDeviceID", SystemInfo.graphicsDeviceID.ToString());
102-
dicSystemInfo.Add("graphicsDeviceType", SystemInfo.graphicsDeviceType.ToString());
103-
dicSystemInfo.Add("graphicsDeviceVendorID", SystemInfo.graphicsDeviceVendorID.ToString());
104-
dicSystemInfo.Add("graphicsDeviceVersion", SystemInfo.graphicsDeviceVersion);
105-
dicSystemInfo.Add("graphicsMultiThreaded", SystemInfo.graphicsMultiThreaded.ToString());
106-
dicSystemInfo.Add("graphicsShaderLevel", SystemInfo.graphicsShaderLevel.ToString());
107-
108-
#if UNITY_5_4_OR_NEWER
109-
dicSystemInfo.Add("copyTextureSupport", SystemInfo.copyTextureSupport.ToString());
110-
#else
111-
dicSystemInfo.Add("copyTextureSupport", "");
112-
#endif
113-
114-
dicSystemInfo.Add("supportsAccelerometer", SystemInfo.supportsAccelerometer.ToString());
115-
dicSystemInfo.Add("supportsGyroscope", SystemInfo.supportsGyroscope.ToString());
116-
dicSystemInfo.Add("supportsVibration", SystemInfo.supportsVibration.ToString());
117-
dicSystemInfo.Add("supportsLocationService", SystemInfo.supportsLocationService.ToString());
118-
119-
return dicSystemInfo;
120-
}
121-
122-
public void OnBackButtonClick ()
123-
{
124-
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
125-
SceneManager.LoadScene ("NatCamWithOpenCVForUnityExample");
126-
#else
127-
Application.LoadLevel ("NatCamWithOpenCVForUnityExample");
128-
#endif
129-
}
130-
}
1+
using UnityEngine;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using UnityEngine.UI;
5+
6+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
7+
using UnityEngine.SceneManagement;
8+
#endif
9+
10+
namespace NatCamWithOpenCVForUnityExample
11+
{
12+
public class ShowSystemInfo : MonoBehaviour
13+
{
14+
public Text systemInfoText;
15+
public InputField systemInfoInputField;
16+
Dictionary<string, string> dicSystemInfo;
17+
18+
// Use this for initialization
19+
void Start ()
20+
{
21+
dicSystemInfo = GetSystemInfo ();
22+
23+
systemInfoText.text = systemInfoInputField.text = "### System Info ###" + "\n";
24+
Debug.Log("### System Info ###");
25+
26+
foreach (string key in dicSystemInfo.Keys)
27+
{
28+
systemInfoText.text = systemInfoInputField.text += key + " = " + dicSystemInfo [key] + "\n";
29+
Debug.Log(key + "=" + dicSystemInfo[key]);
30+
}
31+
32+
systemInfoText.text = systemInfoInputField.text += "###################" + "\n";
33+
Debug.Log("###################");
34+
}
35+
36+
// Update is called once per frame
37+
void Update ()
38+
{
39+
40+
}
41+
42+
public Dictionary<string, string> GetSystemInfo()
43+
{
44+
Dictionary<string, string> dicSystemInfo = new Dictionary<string, string> ();
45+
46+
dicSystemInfo.Add("OpenCVForUnity version", OpenCVForUnity.Core.NATIVE_LIBRARY_NAME + " " + OpenCVForUnity.Utils.getVersion () + " (" + OpenCVForUnity.Core.VERSION + ")");
47+
dicSystemInfo.Add("Build Unity version", Application.unityVersion);
48+
49+
#if UNITY_EDITOR
50+
dicSystemInfo.Add("Build target", "Editor");
51+
#elif UNITY_STANDALONE_WIN
52+
dicSystemInfo.Add("Build target", "Windows");
53+
#elif UNITY_STANDALONE_OSX
54+
dicSystemInfo.Add("Build target", "Mac OSX");
55+
#elif UNITY_STANDALONE_LINUX
56+
dicSystemInfo.Add("Build target", "Linux");
57+
#elif UNITY_ANDROID
58+
dicSystemInfo.Add("Build target", "Android");
59+
#elif UNITY_IOS
60+
dicSystemInfo.Add("Build target", "iOS");
61+
#elif UNITY_WSA
62+
dicSystemInfo.Add("Build target", "WSA");
63+
#elif UNITY_WEBGL
64+
dicSystemInfo.Add("Build target", "WebGL");
65+
#else
66+
dicSystemInfo.Add("Build target", "");
67+
#endif
68+
69+
#if ENABLE_MONO
70+
dicSystemInfo.Add("Scripting backend", "Mono");
71+
#elif ENABLE_IL2CPP
72+
dicSystemInfo.Add("Scripting backend", "IL2CPP");
73+
#elif ENABLE_DOTNET
74+
dicSystemInfo.Add("Scripting backend", ".NET");
75+
#else
76+
dicSystemInfo.Add("Scripting backend", "");
77+
#endif
78+
79+
dicSystemInfo.Add("operatingSystem", SystemInfo.operatingSystem);
80+
81+
#if UNITY_IOS
82+
#if UNITY_5_4_OR_NEWER
83+
dicSystemInfo.Add("iPhone.generation", UnityEngine.iOS.Device.generation.ToString());
84+
#else
85+
dicSystemInfo.Add("iPhone.generation", UnityEngine.iPhone.generation.ToString());
86+
#endif
87+
#else
88+
dicSystemInfo.Add ("iPhone.generation", "");
89+
#endif
90+
91+
//dicSystemInfo.Add("deviceUniqueIdentifier", SystemInfo.deviceUniqueIdentifier);
92+
dicSystemInfo.Add("deviceModel", SystemInfo.deviceModel);
93+
dicSystemInfo.Add("deviceName", SystemInfo.deviceName);
94+
dicSystemInfo.Add("deviceType", SystemInfo.deviceType.ToString());
95+
dicSystemInfo.Add("graphicsDeviceName", SystemInfo.graphicsDeviceName);
96+
dicSystemInfo.Add("graphicsDeviceVendor", SystemInfo.graphicsDeviceVendor);
97+
dicSystemInfo.Add("processorType", SystemInfo.processorType);
98+
dicSystemInfo.Add("graphicsMemorySize", SystemInfo.graphicsMemorySize.ToString());
99+
dicSystemInfo.Add("systemMemorySize", SystemInfo.systemMemorySize.ToString());
100+
101+
dicSystemInfo.Add("graphicsDeviceID", SystemInfo.graphicsDeviceID.ToString());
102+
dicSystemInfo.Add("graphicsDeviceType", SystemInfo.graphicsDeviceType.ToString());
103+
dicSystemInfo.Add("graphicsDeviceVendorID", SystemInfo.graphicsDeviceVendorID.ToString());
104+
dicSystemInfo.Add("graphicsDeviceVersion", SystemInfo.graphicsDeviceVersion);
105+
dicSystemInfo.Add("graphicsMultiThreaded", SystemInfo.graphicsMultiThreaded.ToString());
106+
dicSystemInfo.Add("graphicsShaderLevel", SystemInfo.graphicsShaderLevel.ToString());
107+
108+
#if UNITY_5_4_OR_NEWER
109+
dicSystemInfo.Add("copyTextureSupport", SystemInfo.copyTextureSupport.ToString());
110+
#else
111+
dicSystemInfo.Add("copyTextureSupport", "");
112+
#endif
113+
114+
dicSystemInfo.Add("supportsAccelerometer", SystemInfo.supportsAccelerometer.ToString());
115+
dicSystemInfo.Add("supportsGyroscope", SystemInfo.supportsGyroscope.ToString());
116+
dicSystemInfo.Add("supportsVibration", SystemInfo.supportsVibration.ToString());
117+
dicSystemInfo.Add("supportsLocationService", SystemInfo.supportsLocationService.ToString());
118+
119+
return dicSystemInfo;
120+
}
121+
122+
public void OnBackButtonClick ()
123+
{
124+
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
125+
SceneManager.LoadScene ("NatCamWithOpenCVForUnityExample");
126+
#else
127+
Application.LoadLevel ("NatCamWithOpenCVForUnityExample");
128+
#endif
129+
}
130+
}
131131
}

Diff for: ‎Assets/NatCamWithOpenCVForUnityExample/WebCamTextureOnlyExample/WebCamTextureOnlyExample.cs

+666-473
Large diffs are not rendered by default.

Diff for: ‎Assets/NatCamWithOpenCVForUnityExample/WebCamTextureToMatExample/WebCamTextureToMatExample.cs

+528-548
Large diffs are not rendered by default.

Diff for: ‎README.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
# NatCam With OpenCVForUnity Example
2-
3-
An example of a benchmark test integrating NatCam and OpenCVForUnity.
4-
(Comparison between WebCamTexture and NatCam preview frame)
5-
6-
## Environment
7-
* Anddroid (Pixel, Nexus 7, Zenfone, SC-04E) / iOS (iPhone8, iPhone6)
8-
* Unity 5.6.1f1, Unity 5.6.5f1, Unity 2017.2
9-
* Scripting backend MONO / IL2CPP
10-
* NatCam Pro 1.6f2 ([https://assetstore.unity.com/packages/tools/integration/natcam-pro-webcam-api-52154](https://assetstore.unity.com/packages/tools/integration/natcam-pro-webcam-api-52154))
11-
* OpenCV for Unity 2.2.7 ([https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088](https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088))
12-
13-
14-
Demo
15-
-----
16-
* Android [NatCamWithOpenCVForUnityExample.apk](https://github.com/EnoxSoftware/NatCamWithOpenCVForUnityExample/releases)
17-
18-
19-
## Setup
20-
1. Download latast release unitypackage. [NatCamWithOpenCVForUnityExample.unitypackage](https://github.com/EnoxSoftware/NatCamWithOpenCVForUnityExample/releases)
21-
1. Create a new project. (NatCamWithOpenCVForUnityExample)
22-
1. Import NatCam Pro.
23-
1. Import OpenCVForUnity.
24-
* Setup the OpenCVForUnity. (Tools > OpenCV for Unity > Set Plugn Inport Settings)
25-
1. Import the NatCamWithOpenCVForUnityExample.unitypackage.
26-
1. Add the "Assets/NatCamWithOpenCVForUnityExample/*.unity" files to the "Scenes In Build" list in the "Build Settings" window.
27-
1. Build and Deploy to Androd and iOS.
28-
29-
30-
## ScreenShot
31-
![screenshot01.jpg](screenshot01.jpg)
32-
![screenshot02.jpg](screenshot02.jpg)
33-
34-
1+
# NatCam With OpenCVForUnity Example
2+
3+
An example of a benchmark test integrating NatCam and OpenCVForUnity.
4+
(Comparison between WebCamTexture and NatCam preview frame)
5+
6+
## Environment
7+
* Anddroid (Pixel, Nexus 7, Zenfone, SC-04E) / iOS (iPhone8, iPhone6)
8+
* Unity >= 5.6.1f1
9+
* Scripting backend MONO / IL2CPP
10+
* NatCam Pro 1.6f2 ([https://assetstore.unity.com/packages/tools/integration/natcam-pro-webcam-api-52154](https://assetstore.unity.com/packages/tools/integration/natcam-pro-webcam-api-52154))
11+
* OpenCV for Unity 2.2.8 ([https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088](https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088))
12+
13+
14+
Demo
15+
-----
16+
* Android [NatCamWithOpenCVForUnityExample.apk](https://github.com/EnoxSoftware/NatCamWithOpenCVForUnityExample/releases)
17+
18+
19+
## Setup
20+
1. Download latast release unitypackage. [NatCamWithOpenCVForUnityExample.unitypackage](https://github.com/EnoxSoftware/NatCamWithOpenCVForUnityExample/releases)
21+
1. Create a new project. (NatCamWithOpenCVForUnityExample)
22+
1. Import NatCam Pro.
23+
1. Import OpenCVForUnity.
24+
* Setup the OpenCVForUnity. (Tools > OpenCV for Unity > Set Plugn Inport Settings)
25+
1. Import the NatCamWithOpenCVForUnityExample.unitypackage.
26+
1. Add the "Assets/NatCamWithOpenCVForUnityExample/*.unity" files to the "Scenes In Build" list in the "Build Settings" window.
27+
1. Build and Deploy to Androd and iOS.
28+
29+
30+
## ScreenShot
31+
![screenshot01.jpg](screenshot01.jpg)
32+
![screenshot02.jpg](screenshot02.jpg)
33+
34+

0 commit comments

Comments
 (0)
Please sign in to comment.