forked from EnoxSoftware/OpenCVForUnity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlotSample.cs
More file actions
56 lines (44 loc) · 1.61 KB
/
Copy pathPlotSample.cs
File metadata and controls
56 lines (44 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using UnityEngine;
using System.Collections;
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
using OpenCVForUnity;
namespace OpenCVForUnitySample
{
/// <summary>
/// Plot sample.
/// </summary>
public class PlotSample : MonoBehaviour
{
// Use this for initialization
void Start ()
{
// Plot data must be a 1xN or Nx1 matrix.
// Plot data type must be double (CV_64F)
Mat data = new Mat (30, 1, CvType.CV_64F);
Core.randu (data, 0, 500); // random values
Mat plot_result = new Mat ();
Plot2d plot = Plot.createPlot2d (data);
plot.setPlotBackgroundColor (new Scalar (50, 50, 50));
plot.setPlotLineColor (new Scalar (50, 50, 255));
plot.render (plot_result);
Imgproc.cvtColor (plot_result, plot_result, Imgproc.COLOR_BGR2RGB);
Texture2D texture = new Texture2D (plot_result.cols (), plot_result.rows (), TextureFormat.RGBA32, false);
Utils.matToTexture2D (plot_result, texture);
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
}
// Update is called once per frame
void Update ()
{
}
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("OpenCVForUnitySample");
#else
Application.LoadLevel ("OpenCVForUnitySample");
#endif
}
}
}