v1.0.2 Updated assets version to OpenCVForUnity v2.5.9 / AVProVideo-v2.9.3 / AVProLiveCamera-v2.9.3

This commit is contained in:
EnoxSoftware 2024-03-24 22:14:24 +09:00
Родитель 2f0e4ed928
Коммит f4b6229690
51 изменённых файлов: 13767 добавлений и 3920 удалений

Двоичные данные
AVProWithOpenCVForUnityExample.unitypackage

Двоичный файл не отображается.

Просмотреть файл

@ -1,9 +1,8 @@
fileFormatVersion: 2
guid: 7c5affbbd855e9b4492f319019efe8c5
guid: 5b52f79706bd5bb4ea572b87e9fedf93
folderAsset: yes
timeCreated: 1481630417
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,306 @@
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
using RenderHeads.Media.AVProLiveCamera;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace AVProWithOpenCVForUnityExample
{
/// <summary>
/// AVProLiveCamera AsyncGPUReadback Example
/// An example of converting an AVProLiveCamera image frame to an OpenCV Mat using AsyncGPUReadback.
/// </summary>
public class AVProLiveCameraAsyncGPUReadbackExample : MonoBehaviour
{
public AVProLiveCamera _camera;
private AVProLiveCameraDevice _device;
private int _frameWidth;
private int _frameHeight;
private uint _lastFrame;
private bool _graphicsFormatIsFormatSupported;
/// <summary>
/// The texture.
/// </summary>
Texture2D texture;
/// <summary>
/// The rgba mat.
/// </summary>
Mat rgbaMat;
/// <summary>
/// The m sepia kernel.
/// </summary>
Mat mSepiaKernel;
/// <summary>
/// The m size0.
/// </summary>
Size mSize0;
/// <summary>
/// The m intermediate mat.
/// </summary>
Mat mIntermediateMat;
public enum modeType
{
original,
sepia,
pixelize,
}
/// <summary>
/// The mode.
/// </summary>
modeType mode;
/// <summary>
/// The original mode toggle.
/// </summary>
public Toggle originalModeToggle;
/// <summary>
/// The sepia mode toggle.
/// </summary>
public Toggle sepiaModeToggle;
/// <summary>
/// The pixelize mode toggle.
/// </summary>
public Toggle pixelizeModeToggle;
// Use this for initialization
void Start()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
// sepia
mSepiaKernel = new Mat(4, 4, CvType.CV_32F);
mSepiaKernel.put(0, 0, /* R */0.189f, 0.769f, 0.393f, 0f);
mSepiaKernel.put(1, 0, /* G */0.168f, 0.686f, 0.349f, 0f);
mSepiaKernel.put(2, 0, /* B */0.131f, 0.534f, 0.272f, 0f);
mSepiaKernel.put(3, 0, /* A */0.000f, 0.000f, 0.000f, 1f);
// pixelize
mIntermediateMat = new Mat();
mSize0 = new Size();
}
void Update()
{
if (_camera != null)
_device = _camera.Device;
if (_device != null && _device.IsActive && !_device.IsPaused && _device.OutputTexture != null)
{
if (_device.CurrentWidth != _frameWidth || _device.CurrentHeight != _frameHeight)
{
CreateBuffer(_device.CurrentWidth, _device.CurrentHeight);
}
uint lastFrame = AVProLiveCameraPlugin.GetLastFrame(_device.DeviceIndex);
// Reset _lastFrame at the timing when the camera is reset.
if (lastFrame < _lastFrame)
_lastFrame = 0;
if (lastFrame != _lastFrame)
{
_lastFrame = lastFrame;
//Debug.Log("FrameReady " + lastFrame);
if (_graphicsFormatIsFormatSupported)
{
AsyncGPUReadback.Request(_device.OutputTexture, 0, TextureFormat.RGBA32, (request) => { OnCompleteReadback(request, lastFrame); });
}
}
}
}
void OnCompleteReadback(AsyncGPUReadbackRequest request, long frameIndex)
{
if (request.hasError)
{
Debug.Log("GPU readback error detected. " + frameIndex);
}
else if (request.done)
{
//Debug.Log("Start GPU readback done. "+frameIndex);
//Debug.Log("Thread.CurrentThread.ManagedThreadId " + Thread.CurrentThread.ManagedThreadId);
MatUtils.copyToMat(request.GetData<byte>(), rgbaMat);
Core.flip(rgbaMat, rgbaMat, 0);
if (mode == modeType.original)
{
}
else if (mode == modeType.sepia)
{
Core.transform(rgbaMat, rgbaMat, mSepiaKernel);
}
else if (mode == modeType.pixelize)
{
Imgproc.resize(rgbaMat, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
Imgproc.resize(mIntermediateMat, rgbaMat, rgbaMat.size(), 0.0, 0.0, Imgproc.INTER_NEAREST);
}
Imgproc.putText(rgbaMat, "AVPro With OpenCV for Unity Example", new Point(50, rgbaMat.rows() / 2), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar(255, 0, 0, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText(rgbaMat, "W:" + rgbaMat.width() + " H:" + rgbaMat.height() + " SO:" + Screen.orientation, new Point(5, rgbaMat.rows() - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
//Convert Mat to Texture2D
Utils.matToTexture2D(rgbaMat, texture);
//Debug.Log("End GPU readback done. " + frameIndex);
}
}
private void CreateBuffer(int width, int height)
{
_frameWidth = width;
_frameHeight = height;
texture = new Texture2D(_frameWidth, _frameHeight, TextureFormat.RGBA32, false, false);
rgbaMat = new Mat(texture.height, texture.width, CvType.CV_8UC4);
gameObject.GetComponent<Renderer>().material.mainTexture = texture;
gameObject.transform.localScale = new Vector3(texture.width, texture.height, 1);
Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
float widthScale = (float)Screen.width / width;
float heightScale = (float)Screen.height / height;
if (widthScale < heightScale)
{
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
}
else
{
Camera.main.orthographicSize = height / 2;
}
_graphicsFormatIsFormatSupported = SystemInfo.IsFormatSupported(_device.OutputTexture.graphicsFormat, FormatUsage.ReadPixels);
if (!_graphicsFormatIsFormatSupported)
{
Imgproc.rectangle(rgbaMat, new OpenCVForUnity.CoreModule.Rect(0, 0, rgbaMat.width(), rgbaMat.height()), new Scalar(0, 0, 0, 255), -1);
Imgproc.putText(rgbaMat, _device.OutputTexture.graphicsFormat + " is not supported for AsyncGPUReadback.", new Point(5, rgbaMat.rows() - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
Utils.matToTexture2D(rgbaMat, texture);
}
}
private void FreeBuffer()
{
if (texture)
{
Texture2D.DestroyImmediate(texture);
texture = null;
}
if (rgbaMat != null)
rgbaMat.Dispose();
}
void OnDestroy()
{
AsyncGPUReadback.WaitAllRequests();
FreeBuffer();
if (mSepiaKernel != null)
{
mSepiaKernel.Dispose();
mSepiaKernel = null;
}
if (mIntermediateMat != null)
{
mIntermediateMat.Dispose();
mIntermediateMat = null;
}
}
/// <summary>
/// Raises the back button event.
/// </summary>
public void OnBackButton()
{
SceneManager.LoadScene("AVProWithOpenCVForUnityExample");
}
/// <summary>
/// Raises the original mode toggle event.
/// </summary>
public void OnOriginalModeToggle()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
}
/// <summary>
/// Raises the sepia mode toggle event.
/// </summary>
public void OnSepiaModeToggle()
{
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
}
/// <summary>
/// Raises the pixelize mode toggle event.
/// </summary>
public void OnPixelizeModeToggle()
{
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ae6d1a212fa0cb248abfc1d1429d3bfb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c952e8d11b5d4124baa50fddd200d843

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7beca3352f1757740a94c68b7455327a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,295 @@
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
using RenderHeads.Media.AVProLiveCamera;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace AVProWithOpenCVForUnityExample
{
/// <summary>
/// AVProLiveCamera GetFrameAsColor32 Example
/// An example of converting an AVProLiveCamera image frame to an OpenCV Mat using GetFrameAsColor32.
/// </summary>
public class AVProLiveCameraGetFrameAsColor32Example : MonoBehaviour
{
public AVProLiveCamera _camera;
private AVProLiveCameraDevice _device;
private Color32[] _frameData;
private int _frameWidth;
private int _frameHeight;
private GCHandle _frameHandle;
private System.IntPtr _framePointer;
private uint _lastFrame;
/// <summary>
/// The texture.
/// </summary>
Texture2D texture;
/// <summary>
/// The rgba mat.
/// </summary>
Mat rgbaMat;
/// <summary>
/// The m sepia kernel.
/// </summary>
Mat mSepiaKernel;
/// <summary>
/// The m size0.
/// </summary>
Size mSize0;
/// <summary>
/// The m intermediate mat.
/// </summary>
Mat mIntermediateMat;
public enum modeType
{
original,
sepia,
pixelize,
}
/// <summary>
/// The mode.
/// </summary>
modeType mode;
/// <summary>
/// The original mode toggle.
/// </summary>
public Toggle originalModeToggle;
/// <summary>
/// The sepia mode toggle.
/// </summary>
public Toggle sepiaModeToggle;
/// <summary>
/// The pixelize mode toggle.
/// </summary>
public Toggle pixelizeModeToggle;
// Use this for initialization
void Start()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
// sepia
mSepiaKernel = new Mat(4, 4, CvType.CV_32F);
mSepiaKernel.put(0, 0, /* R */0.189f, 0.769f, 0.393f, 0f);
mSepiaKernel.put(1, 0, /* G */0.168f, 0.686f, 0.349f, 0f);
mSepiaKernel.put(2, 0, /* B */0.131f, 0.534f, 0.272f, 0f);
mSepiaKernel.put(3, 0, /* A */0.000f, 0.000f, 0.000f, 1f);
// pixelize
mIntermediateMat = new Mat();
mSize0 = new Size();
}
void Update()
{
if (_camera != null)
_device = _camera.Device;
if (_device != null && _device.IsActive && !_device.IsPaused)
{
if (_device.CurrentWidth != _frameWidth || _device.CurrentHeight != _frameHeight)
{
CreateBuffer(_device.CurrentWidth, _device.CurrentHeight);
}
uint lastFrame = AVProLiveCameraPlugin.GetLastFrame(_device.DeviceIndex);
// Reset _lastFrame at the timing when the camera is reset.
if (lastFrame < _lastFrame)
_lastFrame = 0;
if (lastFrame != _lastFrame)
{
_lastFrame = lastFrame;
bool result = AVProLiveCameraPlugin.GetFrameAsColor32(_device.DeviceIndex, _framePointer, _frameWidth, _frameHeight);
if (result)
{
MatUtils.copyToMat<Color32>(_frameData, rgbaMat);
if (mode == modeType.original)
{
}
else if (mode == modeType.sepia)
{
Core.transform(rgbaMat, rgbaMat, mSepiaKernel);
}
else if (mode == modeType.pixelize)
{
Imgproc.resize(rgbaMat, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
Imgproc.resize(mIntermediateMat, rgbaMat, rgbaMat.size(), 0.0, 0.0, Imgproc.INTER_NEAREST);
}
Imgproc.putText(rgbaMat, "AVPro With OpenCV for Unity Example", new Point(50, rgbaMat.rows() / 2), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar(255, 0, 0, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText(rgbaMat, "W:" + rgbaMat.width() + " H:" + rgbaMat.height() + " SO:" + Screen.orientation, new Point(5, rgbaMat.rows() - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
//Convert Mat to Texture2D
Utils.matToTexture2D(rgbaMat, texture);
}
}
}
}
private void CreateBuffer(int width, int height)
{
// Free buffer if it's diffarent size
if (_frameHandle.IsAllocated && _frameData != null)
{
if (_frameData.Length != width * height)
{
FreeBuffer();
}
}
if (_frameData == null)
{
_frameWidth = width;
_frameHeight = height;
_frameData = new Color32[_frameWidth * _frameHeight];
_frameHandle = GCHandle.Alloc(_frameData, GCHandleType.Pinned);
_framePointer = _frameHandle.AddrOfPinnedObject();
texture = new Texture2D(_frameWidth, _frameHeight, TextureFormat.RGBA32, false, false);
rgbaMat = new Mat(texture.height, texture.width, CvType.CV_8UC4);
gameObject.GetComponent<Renderer>().material.mainTexture = texture;
gameObject.transform.localScale = new Vector3(texture.width, texture.height, 1);
Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
float widthScale = (float)Screen.width / width;
float heightScale = (float)Screen.height / height;
if (widthScale < heightScale)
{
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
}
else
{
Camera.main.orthographicSize = height / 2;
}
}
}
private void FreeBuffer()
{
if (_frameHandle.IsAllocated)
{
_framePointer = System.IntPtr.Zero;
_frameHandle.Free();
_frameData = null;
}
if (texture)
{
Texture2D.DestroyImmediate(texture);
texture = null;
}
if (rgbaMat != null)
rgbaMat.Dispose();
}
void OnDestroy()
{
FreeBuffer();
if (mSepiaKernel != null)
{
mSepiaKernel.Dispose();
mSepiaKernel = null;
}
if (mIntermediateMat != null)
{
mIntermediateMat.Dispose();
mIntermediateMat = null;
}
}
/// <summary>
/// Raises the back button event.
/// </summary>
public void OnBackButton()
{
SceneManager.LoadScene("AVProWithOpenCVForUnityExample");
}
/// <summary>
/// Raises the original mode toggle event.
/// </summary>
public void OnOriginalModeToggle()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
}
/// <summary>
/// Raises the sepia mode toggle event.
/// </summary>
public void OnSepiaModeToggle()
{
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
}
/// <summary>
/// Raises the pixelize mode toggle event.
/// </summary>
public void OnPixelizeModeToggle()
{
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 50481e624086a834188f8f07111ac0c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 8d03a8d964fc0344b92e785a6f8d7ecb

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0c543920ca160fc419655af80de5cb6a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,352 @@
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
using RenderHeads.Media.AVProVideo;
using System.Linq;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace AVProWithOpenCVForUnityExample
{
/// <summary>
/// AVProVideo AsyncGPUReadback Example
/// An example of converting an AVProVideo image frame to an OpenCV Mat using AsyncGPUReadback.
/// </summary>
public class AVProVideoAsyncGPUReadbackExample : MonoBehaviour
{
/// <summary>
/// The media player.
/// </summary>
public MediaPlayer mediaPlayer;
private int _lastFrame;
private bool _graphicsFormatIsFormatSupported;
/// <summary>
/// The texture.
/// </summary>
Texture2D texture;
/// <summary>
/// The rgba mat.
/// </summary>
Mat rgbaMat;
/// <summary>
/// The m sepia kernel.
/// </summary>
Mat mSepiaKernel;
/// <summary>
/// The m size0.
/// </summary>
Size mSize0;
/// <summary>
/// The m intermediate mat.
/// </summary>
Mat mIntermediateMat;
public enum modeType
{
original,
sepia,
pixelize,
}
/// <summary>
/// The mode.
/// </summary>
modeType mode;
/// <summary>
/// The original mode toggle.
/// </summary>
public Toggle originalModeToggle;
/// <summary>
/// The sepia mode toggle.
/// </summary>
public Toggle sepiaModeToggle;
/// <summary>
/// The pixelize mode toggle.
/// </summary>
public Toggle pixelizeModeToggle;
// Use this for initialization
void Start()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
// sepia
mSepiaKernel = new Mat(4, 4, CvType.CV_32F);
mSepiaKernel.put(0, 0, /* R */0.189f, 0.769f, 0.393f, 0f);
mSepiaKernel.put(1, 0, /* G */0.168f, 0.686f, 0.349f, 0f);
mSepiaKernel.put(2, 0, /* B */0.131f, 0.534f, 0.272f, 0f);
mSepiaKernel.put(3, 0, /* A */0.000f, 0.000f, 0.000f, 1f);
// pixelize
mIntermediateMat = new Mat();
mSize0 = new Size();
mediaPlayer.Events.AddListener(OnVideoEvent);
//
ReadbackSupport();
//
}
//
public void ReadbackSupport()
{
var read_formats = System.Enum.GetValues(typeof(GraphicsFormat)).Cast<GraphicsFormat>()
.Where(f => SystemInfo.IsFormatSupported(f, FormatUsage.ReadPixels))
.ToArray();
Debug.Log("AsyncGPUReadbackSupportedGraphicsFormats:\n" + string.Join("\n", read_formats));
}
//
// Update is called once per frame
void Update()
{
if (texture != null)
{
IMediaControl control = mediaPlayer.Control;
int lastFrame = control.GetCurrentTimeFrames();
// Reset _lastFrame at the timing when the video is reset.
if (lastFrame < _lastFrame)
_lastFrame = 0;
if (lastFrame != _lastFrame)
{
_lastFrame = lastFrame;
//Debug.Log("FrameReady " + lastFrame);
if (_graphicsFormatIsFormatSupported)
{
AsyncGPUReadback.Request(mediaPlayer.TextureProducer.GetTexture(), 0, TextureFormat.RGBA32, (request) => { OnCompleteReadback(request, lastFrame); });
}
}
}
}
void OnCompleteReadback(AsyncGPUReadbackRequest request, long frameIndex)
{
if (request.hasError)
{
Debug.Log("GPU readback error detected. " + frameIndex);
}
else if (request.done)
{
//Debug.Log("Start GPU readback done. "+frameIndex);
//Debug.Log("Thread.CurrentThread.ManagedThreadId " + Thread.CurrentThread.ManagedThreadId);
MatUtils.copyToMat(request.GetData<byte>(), rgbaMat);
//Core.flip(rgbaMat, rgbaMat, 0);
if (mode == modeType.original)
{
}
else if (mode == modeType.sepia)
{
Core.transform(rgbaMat, rgbaMat, mSepiaKernel);
}
else if (mode == modeType.pixelize)
{
Imgproc.resize(rgbaMat, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
Imgproc.resize(mIntermediateMat, rgbaMat, rgbaMat.size(), 0.0, 0.0, Imgproc.INTER_NEAREST);
}
Imgproc.putText(rgbaMat, "AVPro With OpenCV for Unity Example", new Point(50, rgbaMat.rows() / 2), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar(255, 0, 0, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText(rgbaMat, "W:" + rgbaMat.width() + " H:" + rgbaMat.height() + " SO:" + Screen.orientation, new Point(5, rgbaMat.rows() - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
//Convert Mat to Texture2D
Utils.matToTexture2D(rgbaMat, texture);
//Debug.Log("End GPU readback done. " + frameIndex);
}
}
// Callback function to handle events
public void OnVideoEvent(MediaPlayer mp, MediaPlayerEvent.EventType et,
ErrorCode errorCode)
{
switch (et)
{
case MediaPlayerEvent.EventType.ReadyToPlay:
mediaPlayer.Control.Play();
break;
case MediaPlayerEvent.EventType.FirstFrameReady:
Debug.Log("First frame ready");
OnNewMediaReady();
break;
case MediaPlayerEvent.EventType.FinishedPlaying:
mediaPlayer.Control.Rewind();
break;
}
Debug.Log("Event: " + et.ToString());
}
/// <summary>
/// Raises the new media ready event.
/// </summary>
private void OnNewMediaReady()
{
IMediaInfo info = mediaPlayer.Info;
Debug.Log("GetVideoWidth " + info.GetVideoWidth() + " GetVideoHeight() " + info.GetVideoHeight());
// Create a texture the same resolution as our video
if (texture != null)
{
Texture2D.Destroy(texture);
texture = null;
}
texture = new Texture2D(info.GetVideoWidth(), info.GetVideoHeight(), TextureFormat.RGBA32, false);
rgbaMat = new Mat(texture.height, texture.width, CvType.CV_8UC4);
gameObject.GetComponent<Renderer>().material.mainTexture = texture;
gameObject.transform.localScale = new Vector3(texture.width, texture.height, 1);
Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
float width = texture.width;
float height = texture.height;
float widthScale = (float)Screen.width / width;
float heightScale = (float)Screen.height / height;
if (widthScale < heightScale)
{
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
}
else
{
Camera.main.orthographicSize = height / 2;
}
_graphicsFormatIsFormatSupported = SystemInfo.IsFormatSupported(mediaPlayer.TextureProducer.GetTexture().graphicsFormat, FormatUsage.ReadPixels);
if (!_graphicsFormatIsFormatSupported)
{
Imgproc.rectangle(rgbaMat, new OpenCVForUnity.CoreModule.Rect(0, 0, rgbaMat.width(), rgbaMat.height()), new Scalar(0, 0, 0, 255), -1);
Imgproc.putText(rgbaMat, mediaPlayer.TextureProducer.GetTexture().graphicsFormat + " is not supported for AsyncGPUReadback.", new Point(5, rgbaMat.rows() - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
Utils.matToTexture2D(rgbaMat, texture);
}
}
/// <summary>
/// Raises the destroy event.
/// </summary>
void OnDestroy()
{
AsyncGPUReadback.WaitAllRequests();
if (texture != null)
{
Texture2D.Destroy(texture);
texture = null;
}
if (mSepiaKernel != null)
{
mSepiaKernel.Dispose();
mSepiaKernel = null;
}
if (mIntermediateMat != null)
{
mIntermediateMat.Dispose();
mIntermediateMat = null;
}
}
/// <summary>
/// Raises the back button event.
/// </summary>
public void OnBackButton()
{
SceneManager.LoadScene("AVProWithOpenCVForUnityExample");
}
/// <summary>
/// Raises the original mode toggle event.
/// </summary>
public void OnOriginalModeToggle()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
}
/// <summary>
/// Raises the sepia mode toggle event.
/// </summary>
public void OnSepiaModeToggle()
{
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
}
/// <summary>
/// Raises the pixelize mode toggle event.
/// </summary>
public void OnPixelizeModeToggle()
{
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
}
}
}

Просмотреть файл

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a8cbcbf9b572da847968f474eff427fc
timeCreated: 1481630932
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3a3cc0eccff92be45a48ab04922797a0
timeCreated: 1481556427
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5c1ad4319f41e434aa9391912311a971
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,293 @@
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
using RenderHeads.Media.AVProVideo;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace AVProWithOpenCVForUnityExample
{
/// <summary>
/// AVProVideo ExtractFrame Example
/// An example of converting an AVProVideo image frame to an OpenCV Mat using ExtractFrame.
/// </summary>
public class AVProVideoExtractFrameExample : MonoBehaviour
{
private const int TARGET_FRAME_NUMBER = 100;
private float _timeSeconds = 0f;
public bool _accurateSeek = false;
public int _timeoutMs = 250;
/// <summary>
/// The media player.
/// </summary>
public MediaPlayer mediaPlayer;
/// <summary>
/// The texture.
/// </summary>
Texture2D texture;
/// <summary>
/// The rgba mat.
/// </summary>
Mat rgbaMat;
/// <summary>
/// The m sepia kernel.
/// </summary>
Mat mSepiaKernel;
/// <summary>
/// The m size0.
/// </summary>
Size mSize0;
/// <summary>
/// The m intermediate mat.
/// </summary>
Mat mIntermediateMat;
public enum modeType
{
original,
sepia,
pixelize,
}
/// <summary>
/// The mode.
/// </summary>
modeType mode;
/// <summary>
/// The original mode toggle.
/// </summary>
public Toggle originalModeToggle;
/// <summary>
/// The sepia mode toggle.
/// </summary>
public Toggle sepiaModeToggle;
/// <summary>
/// The pixelize mode toggle.
/// </summary>
public Toggle pixelizeModeToggle;
// Use this for initialization
void Start()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
// sepia
mSepiaKernel = new Mat(4, 4, CvType.CV_32F);
mSepiaKernel.put(0, 0, /* R */0.189f, 0.769f, 0.393f, 0f);
mSepiaKernel.put(1, 0, /* G */0.168f, 0.686f, 0.349f, 0f);
mSepiaKernel.put(2, 0, /* B */0.131f, 0.534f, 0.272f, 0f);
mSepiaKernel.put(3, 0, /* A */0.000f, 0.000f, 0.000f, 1f);
// pixelize
mIntermediateMat = new Mat();
mSize0 = new Size();
mediaPlayer.Events.AddListener(OnVideoEvent);
}
// Update is called once per frame
void Update()
{
if (texture != null)
{
//Convert AVPro's Texture to Texture2D
mediaPlayer.ExtractFrame(texture, _timeSeconds, _accurateSeek, _timeoutMs);
//Convert Texture2D to Mat
Utils.texture2DToMat(texture, rgbaMat);
if (mode == modeType.original)
{
}
else if (mode == modeType.sepia)
{
Core.transform(rgbaMat, rgbaMat, mSepiaKernel);
}
else if (mode == modeType.pixelize)
{
Imgproc.resize(rgbaMat, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
Imgproc.resize(mIntermediateMat, rgbaMat, rgbaMat.size(), 0.0, 0.0, Imgproc.INTER_NEAREST);
}
Imgproc.putText(rgbaMat, "AVPro With OpenCV for Unity Example", new Point(50, rgbaMat.rows() / 2), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar(255, 0, 0, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText(rgbaMat, "ExtractFrame: " + TARGET_FRAME_NUMBER + "( " + _timeSeconds + "sec )", new Point(50, rgbaMat.rows() / 2 + 60), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar(0, 0, 255, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText(rgbaMat, "W:" + rgbaMat.width() + " H:" + rgbaMat.height() + " SO:" + Screen.orientation, new Point(5, rgbaMat.rows() - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
//Convert Mat to Texture2D
Utils.matToTexture2D(rgbaMat, texture);
}
}
// Callback function to handle events
public void OnVideoEvent(MediaPlayer mp, MediaPlayerEvent.EventType et,
ErrorCode errorCode)
{
switch (et)
{
case MediaPlayerEvent.EventType.ReadyToPlay:
mediaPlayer.Control.Play();
mediaPlayer.Control.Pause();
break;
case MediaPlayerEvent.EventType.FirstFrameReady:
Debug.Log("First frame ready");
OnNewMediaReady();
break;
case MediaPlayerEvent.EventType.FinishedPlaying:
mediaPlayer.Control.Rewind();
break;
}
Debug.Log("Event: " + et.ToString());
}
/// <summary>
/// Raises the new media ready event.
/// </summary>
private void OnNewMediaReady()
{
IMediaInfo info = mediaPlayer.Info;
Debug.Log("GetVideoWidth " + info.GetVideoWidth() + " GetVideoHeight() " + info.GetVideoHeight());
// Create a texture the same resolution as our video
if (texture != null)
{
Texture2D.Destroy(texture);
texture = null;
}
texture = new Texture2D(info.GetVideoWidth(), info.GetVideoHeight(), TextureFormat.RGBA32, false);
rgbaMat = new Mat(texture.height, texture.width, CvType.CV_8UC4);
gameObject.GetComponent<Renderer>().material.mainTexture = texture;
gameObject.transform.localScale = new Vector3(texture.width, texture.height, 1);
Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
float width = texture.width;
float height = texture.height;
float widthScale = (float)Screen.width / width;
float heightScale = (float)Screen.height / height;
if (widthScale < heightScale)
{
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
}
else
{
Camera.main.orthographicSize = height / 2;
}
_timeSeconds = 1f / info.GetVideoFrameRate() * TARGET_FRAME_NUMBER;
}
/// <summary>
/// Raises the destroy event.
/// </summary>
void OnDestroy()
{
if (texture != null)
{
Texture2D.Destroy(texture);
texture = null;
}
if (mSepiaKernel != null)
{
mSepiaKernel.Dispose();
mSepiaKernel = null;
}
if (mIntermediateMat != null)
{
mIntermediateMat.Dispose();
mIntermediateMat = null;
}
}
/// <summary>
/// Raises the back button event.
/// </summary>
public void OnBackButton()
{
SceneManager.LoadScene("AVProWithOpenCVForUnityExample");
}
/// <summary>
/// Raises the original mode toggle event.
/// </summary>
public void OnOriginalModeToggle()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
}
/// <summary>
/// Raises the sepia mode toggle event.
/// </summary>
public void OnSepiaModeToggle()
{
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
}
/// <summary>
/// Raises the pixelize mode toggle event.
/// </summary>
public void OnPixelizeModeToggle()
{
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
}
}
}

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0d2a3439faad07f46b3c8549a224c602
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,300 @@
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
using RenderHeads.Media.AVProVideo;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace AVProWithOpenCVForUnityExample
{
/// <summary>
/// AVProVideo GetReadableTexture Example
/// An example of converting an AVProVideo image frame to an OpenCV Mat using GetReadableTexture.
/// </summary>
public class AVProVideoGetReadableTextureExample : MonoBehaviour
{
/// <summary>
/// The media player.
/// </summary>
public MediaPlayer mediaPlayer;
private int _lastFrame;
/// <summary>
/// The texture.
/// </summary>
Texture2D texture;
/// <summary>
/// The rgba mat.
/// </summary>
Mat rgbaMat;
/// <summary>
/// The m sepia kernel.
/// </summary>
Mat mSepiaKernel;
/// <summary>
/// The m size0.
/// </summary>
Size mSize0;
/// <summary>
/// The m intermediate mat.
/// </summary>
Mat mIntermediateMat;
public enum modeType
{
original,
sepia,
pixelize,
}
/// <summary>
/// The mode.
/// </summary>
modeType mode;
/// <summary>
/// The original mode toggle.
/// </summary>
public Toggle originalModeToggle;
/// <summary>
/// The sepia mode toggle.
/// </summary>
public Toggle sepiaModeToggle;
/// <summary>
/// The pixelize mode toggle.
/// </summary>
public Toggle pixelizeModeToggle;
// Use this for initialization
void Start()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
// sepia
mSepiaKernel = new Mat(4, 4, CvType.CV_32F);
mSepiaKernel.put(0, 0, /* R */0.189f, 0.769f, 0.393f, 0f);
mSepiaKernel.put(1, 0, /* G */0.168f, 0.686f, 0.349f, 0f);
mSepiaKernel.put(2, 0, /* B */0.131f, 0.534f, 0.272f, 0f);
mSepiaKernel.put(3, 0, /* A */0.000f, 0.000f, 0.000f, 1f);
// pixelize
mIntermediateMat = new Mat();
mSize0 = new Size();
mediaPlayer.Events.AddListener(OnVideoEvent);
}
// Update is called once per frame
void Update()
{
if (texture != null)
{
IMediaControl control = mediaPlayer.Control;
int lastFrame = control.GetCurrentTimeFrames();
// Reset _lastFrame at the timing when the video is reset.
if (lastFrame < _lastFrame)
_lastFrame = 0;
if (lastFrame != _lastFrame)
{
_lastFrame = lastFrame;
//Debug.Log("FrameReady " + lastFrame);
//Convert AVPro's Texture to Texture2D
Helper.GetReadableTexture(mediaPlayer.TextureProducer.GetTexture(), mediaPlayer.TextureProducer.RequiresVerticalFlip(), Helper.GetOrientation(mediaPlayer.Info.GetTextureTransform()), texture);
//Convert Texture2D to Mat
Utils.texture2DToMat(texture, rgbaMat);
if (mode == modeType.original)
{
}
else if (mode == modeType.sepia)
{
Core.transform(rgbaMat, rgbaMat, mSepiaKernel);
}
else if (mode == modeType.pixelize)
{
Imgproc.resize(rgbaMat, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
Imgproc.resize(mIntermediateMat, rgbaMat, rgbaMat.size(), 0.0, 0.0, Imgproc.INTER_NEAREST);
}
Imgproc.putText(rgbaMat, "AVPro With OpenCV for Unity Example", new Point(50, rgbaMat.rows() / 2), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar(255, 0, 0, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText(rgbaMat, "W:" + rgbaMat.width() + " H:" + rgbaMat.height() + " SO:" + Screen.orientation, new Point(5, rgbaMat.rows() - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar(255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
//Convert Mat to Texture2D
Utils.matToTexture2D(rgbaMat, texture);
}
}
}
// Callback function to handle events
public void OnVideoEvent(MediaPlayer mp, MediaPlayerEvent.EventType et,
ErrorCode errorCode)
{
switch (et)
{
case MediaPlayerEvent.EventType.ReadyToPlay:
mediaPlayer.Control.Play();
break;
case MediaPlayerEvent.EventType.FirstFrameReady:
Debug.Log("First frame ready");
OnNewMediaReady();
break;
case MediaPlayerEvent.EventType.FinishedPlaying:
mediaPlayer.Control.Rewind();
break;
}
Debug.Log("Event: " + et.ToString());
}
/// <summary>
/// Raises the new media ready event.
/// </summary>
private void OnNewMediaReady()
{
IMediaInfo info = mediaPlayer.Info;
Debug.Log("GetVideoWidth " + info.GetVideoWidth() + " GetVideoHeight() " + info.GetVideoHeight());
// Create a texture the same resolution as our video
if (texture != null)
{
Texture2D.Destroy(texture);
texture = null;
}
texture = new Texture2D(info.GetVideoWidth(), info.GetVideoHeight(), TextureFormat.RGBA32, false);
rgbaMat = new Mat(texture.height, texture.width, CvType.CV_8UC4);
gameObject.GetComponent<Renderer>().material.mainTexture = texture;
gameObject.transform.localScale = new Vector3(texture.width, texture.height, 1);
Debug.Log("Screen.width " + Screen.width + " Screen.height " + Screen.height + " Screen.orientation " + Screen.orientation);
float width = texture.width;
float height = texture.height;
float widthScale = (float)Screen.width / width;
float heightScale = (float)Screen.height / height;
if (widthScale < heightScale)
{
Camera.main.orthographicSize = (width * (float)Screen.height / (float)Screen.width) / 2;
}
else
{
Camera.main.orthographicSize = height / 2;
}
}
/// <summary>
/// Raises the destroy event.
/// </summary>
void OnDestroy()
{
if (texture != null)
{
Texture2D.Destroy(texture);
texture = null;
}
if (mSepiaKernel != null)
{
mSepiaKernel.Dispose();
mSepiaKernel = null;
}
if (mIntermediateMat != null)
{
mIntermediateMat.Dispose();
mIntermediateMat = null;
}
}
/// <summary>
/// Raises the back button event.
/// </summary>
public void OnBackButton()
{
SceneManager.LoadScene("AVProWithOpenCVForUnityExample");
}
/// <summary>
/// Raises the original mode toggle event.
/// </summary>
public void OnOriginalModeToggle()
{
if (originalModeToggle.isOn)
{
mode = modeType.original;
}
}
/// <summary>
/// Raises the sepia mode toggle event.
/// </summary>
public void OnSepiaModeToggle()
{
if (sepiaModeToggle.isOn)
{
mode = modeType.sepia;
}
}
/// <summary>
/// Raises the pixelize mode toggle event.
/// </summary>
public void OnPixelizeModeToggle()
{
if (pixelizeModeToggle.isOn)
{
mode = modeType.pixelize;
}
}
}
}

Просмотреть файл

@ -0,0 +1,97 @@
using System.Collections;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
namespace AVProWithOpenCVForUnityExample
{
public class AVProWithOpenCVForUnityExample : MonoBehaviour
{
[Header("UI")]
public Text exampleTitle;
public Text versionInfo;
public ScrollRect scrollRect;
private static float verticalNormalizedPosition = 1f;
void Awake()
{
//QualitySettings.vSyncCount = 0;
//Application.targetFrameRate = 60;
}
IEnumerator Start()
{
exampleTitle.text = "AVProWithOpenCVForUnity Example " + Application.version;
versionInfo.text = OpenCVForUnity.CoreModule.Core.NATIVE_LIBRARY_NAME + " " + OpenCVForUnity.UnityUtils.Utils.getVersion() + " (" + OpenCVForUnity.CoreModule.Core.VERSION + ")";
versionInfo.text += " / UnityEditor " + Application.unityVersion;
versionInfo.text += " / ";
#if UNITY_EDITOR
versionInfo.text += "Editor";
#elif UNITY_STANDALONE_WIN
versionInfo.text += "Windows";
#elif UNITY_STANDALONE_OSX
versionInfo.text += "Mac OSX";
#elif UNITY_STANDALONE_LINUX
versionInfo.text += "Linux";
#elif UNITY_ANDROID
versionInfo.text += "Android";
#elif UNITY_IOS
versionInfo.text += "iOS";
#elif UNITY_WSA
versionInfo.text += "WSA";
#elif UNITY_WEBGL
versionInfo.text += "WebGL";
#endif
versionInfo.text += " ";
#if ENABLE_MONO
versionInfo.text += "Mono";
#elif ENABLE_IL2CPP
versionInfo.text += "IL2CPP";
#elif ENABLE_DOTNET
versionInfo.text += ".NET";
#endif
scrollRect.verticalNormalizedPosition = verticalNormalizedPosition;
yield break;
}
public void OnScrollRectValueChanged()
{
verticalNormalizedPosition = scrollRect.verticalNormalizedPosition;
}
public void OnShowLicenseButton()
{
SceneManager.LoadScene("ShowLicense");
}
public void OnAVProVideoGetReadableTextureExampleButton()
{
SceneManager.LoadScene("AVProVideoGetReadableTextureExample");
}
public void OnAVProVideoAsyncGPUReadbackExampleButton()
{
SceneManager.LoadScene("AVProVideoAsyncGPUReadbackExample");
}
public void OnAVProVideoExtractFrameExampleButton()
{
SceneManager.LoadScene("AVProVideoExtractFrameExample");
}
public void OnAVProLiveCameraGetFrameAsColor32ExampleButton()
{
SceneManager.LoadScene("AVProLiveCameraGetFrameAsColor32Example");
}
public void OnAVProLiveCameraAsyncGPUReadbackExampleButton()
{
SceneManager.LoadScene("AVProLiveCameraAsyncGPUReadbackExample");
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 03ddd4e615f3fae44a8b4f6dfb4308b5
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,974 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!29 &1
SceneSettings:
m_ObjectHideFlags: 0
m_PVSData:
m_PVSObjectsArray: []
m_PVSPortalsArray: []
m_OcclusionBakeSettings:
smallestOccluder: 5
smallestHole: .25
backfaceThreshold: 100
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 6
m_Fog: 0
m_FogColor: {r: .5, g: .5, b: .5, a: 1}
m_FogMode: 3
m_FogDensity: .00999999978
m_LinearFogStart: 0
m_LinearFogEnd: 300
m_AmbientSkyColor: {r: .200000003, g: .200000003, b: .200000003, a: 1}
m_AmbientEquatorColor: {r: .200000003, g: .200000003, b: .200000003, a: 1}
m_AmbientGroundColor: {r: .200000003, g: .200000003, b: .200000003, a: 1}
m_AmbientIntensity: 1
m_AmbientMode: 3
m_SkyboxMaterial: {fileID: 0}
m_HaloStrength: .5
m_FlareStrength: 1
m_FlareFadeSpeed: 3
m_HaloTexture: {fileID: 0}
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
m_DefaultReflectionMode: 0
m_DefaultReflectionResolution: 128
m_ReflectionBounces: 1
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
--- !u!127 &3
LevelGameManager:
m_ObjectHideFlags: 0
--- !u!157 &4
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 5
m_GIWorkflowMode: 1
m_LightmapsMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_TemporalCoherenceThreshold: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 3
m_Resolution: 1
m_BakeResolution: 50
m_TextureWidth: 1024
m_TextureHeight: 1024
m_AOMaxDistance: 1
m_Padding: 2
m_CompAOExponent: 0
m_LightmapParameters: {fileID: 0}
m_TextureCompression: 0
m_FinalGather: 0
m_FinalGatherRayCount: 1024
m_LightmapSnapshot: {fileID: 0}
m_RuntimeCPUUsage: 25
--- !u!196 &5
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 2
agentRadius: .5
agentHeight: 2
agentSlope: 45
agentClimb: .400000006
ledgeDropHeight: 0
maxJumpAcrossDistance: 0
accuratePlacement: 0
minRegionArea: 2
cellSize: .166666657
manualCellSize: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &38156656
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 38156657}
- 114: {fileID: 38156661}
- 114: {fileID: 38156660}
- 222: {fileID: 38156659}
- 114: {fileID: 38156658}
m_Layer: 5
m_Name: ScrollView
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &38156657
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38156656}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1086899404}
m_Father: {fileID: 1646839690}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -10, y: 0}
m_SizeDelta: {x: -20, y: 0}
m_Pivot: {x: .5, y: 1}
--- !u!114 &38156658
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38156656}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &38156659
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38156656}
--- !u!114 &38156660
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38156656}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -1200242548, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_ShowMaskGraphic: 0
--- !u!114 &38156661
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38156656}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1367256648, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Content: {fileID: 1086899404}
m_Horizontal: 0
m_Vertical: 1
m_MovementType: 1
m_Elasticity: .100000001
m_Inertia: 1
m_DecelerationRate: .135000005
m_ScrollSensitivity: 1
m_HorizontalScrollbar: {fileID: 0}
m_VerticalScrollbar: {fileID: 155392644}
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.ScrollRect+ScrollRectEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!1 &155392642
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 155392643}
- 222: {fileID: 155392646}
- 114: {fileID: 155392645}
- 114: {fileID: 155392644}
m_Layer: 5
m_Name: Scrollbar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &155392643
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 155392642}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 823457167}
m_Father: {fileID: 1646839690}
m_RootOrder: 1
m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -5, y: 0}
m_SizeDelta: {x: 20, y: 0}
m_Pivot: {x: .5, y: .5}
--- !u!114 &155392644
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 155392642}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -2061169968, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
m_ColorMultiplier: 1
m_FadeDuration: .100000001
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1011219729}
m_HandleRect: {fileID: 1011219728}
m_Direction: 2
m_Value: 1
m_Size: .490209013
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.Scrollbar+ScrollEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &155392645
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 155392642}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &155392646
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 155392642}
--- !u!1 &316492814
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 316492818}
- 114: {fileID: 316492817}
- 114: {fileID: 316492816}
- 114: {fileID: 316492815}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &316492815
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 316492814}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1997211142, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_AllowActivationOnStandalone: 0
--- !u!114 &316492816
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 316492814}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1077351063, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_AllowActivationOnMobileDevice: 0
--- !u!114 &316492817
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 316492814}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -619905303, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_FirstSelected: {fileID: 0}
m_sendNavigationEvents: 1
m_DragThreshold: 5
--- !u!4 &316492818
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 316492814}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
--- !u!1 &432530561
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 432530562}
- 222: {fileID: 432530565}
- 114: {fileID: 432530564}
- 114: {fileID: 432530563}
m_Layer: 5
m_Name: BackButton
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &432530562
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 432530561}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 531596783}
m_Father: {fileID: 1502237571}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 10, y: -10.0000305}
m_SizeDelta: {x: 160, y: 40}
m_Pivot: {x: 0, y: 1}
--- !u!114 &432530563
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 432530561}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: .960784316, g: .960784316, b: .960784316, a: 1}
m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
m_ColorMultiplier: 1
m_FadeDuration: .100000001
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 432530564}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1787239750}
m_MethodName: OnBackButton
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine, Version=0.0.0.0,
Culture=neutral, PublicKeyToken=null
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &432530564
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 432530561}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &432530565
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 432530561}
--- !u!1 &531596782
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 531596783}
- 222: {fileID: 531596785}
- 114: {fileID: 531596784}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &531596783
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 531596782}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 432530562}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: .5, y: .5}
--- !u!114 &531596784
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 531596782}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: .195999995, g: .195999995, b: .195999995, a: 1}
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Back
--- !u!222 &531596785
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 531596782}
--- !u!1 &823457166
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 823457167}
m_Layer: 5
m_Name: Sliding Area
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &823457167
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 823457166}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1011219728}
m_Father: {fileID: 155392643}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: -20, y: -20}
m_Pivot: {x: .5, y: .5}
--- !u!1 &1011219727
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 1011219728}
- 222: {fileID: 1011219730}
- 114: {fileID: 1011219729}
m_Layer: 5
m_Name: Handle
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1011219728
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1011219727}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 823457167}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 20, y: 20}
m_Pivot: {x: .5, y: .5}
--- !u!114 &1011219729
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1011219727}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &1011219730
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1011219727}
--- !u!1 &1086899403
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 1086899404}
- 222: {fileID: 1086899406}
- 114: {fileID: 1086899405}
- 114: {fileID: 1086899407}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1086899404
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1086899403}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 38156657}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 1.23977661e-05, y: -9.15527344e-05}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: .5, y: 1}
--- !u!114 &1086899405
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1086899403}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 20
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: "IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r\n\r\n
By downloading, copying, installing or using the software you agree to this license.\r\n
If you do not agree to this license, do not download, install,\r\n copy or use
the software.\r\n\r\n\r\n License Agreement\r\n For
Open Source Computer Vision Library\r\n\r\nCopyright (C) 2000-2008, Intel Corporation,
all rights reserved.\r\nCopyright (C) 2008-2011, Willow Garage Inc., all rights
reserved.\r\nThird party copyrights are property of their respective owners.\r\n\r\nRedistribution
and use in source and binary forms, with or without modification,\r\nare permitted
provided that the following conditions are met:\r\n\r\n * Redistributions of
source code must retain the above copyright notice,\r\n this list of conditions
and the following disclaimer.\r\n\r\n * Redistributions in binary form must reproduce
the above copyright notice,\r\n this list of conditions and the following disclaimer
in the documentation\r\n and/or other materials provided with the distribution.\r\n\r\n
\ * The name of the copyright holders may not be used to endorse or promote products\r\n
\ derived from this software without specific prior written permission.\r\n\r\nThis
software is provided by the copyright holders and contributors \"as is\" and\r\nany
express or implied warranties, including, but not limited to, the implied\r\nwarranties
of merchantability and fitness for a particular purpose are disclaimed.\r\nIn
no event shall the Intel Corporation or contributors be liable for any direct,\r\nindirect,
incidental, special, exemplary, or consequential damages\r\n(including, but not
limited to, procurement of substitute goods or services;\r\nloss of use, data,
or profits; or business interruption) however caused\r\nand on any theory of liability,
whether in contract, strict liability,\r\nor tort (including negligence or otherwise)
arising in any way out of\r\nthe use of this software, even if advised of the
possibility of such damage.\r\n"
--- !u!222 &1086899406
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1086899403}
--- !u!114 &1086899407
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1086899403}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1741964061, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_HorizontalFit: 0
m_VerticalFit: 2
--- !u!1 &1502237567
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 1502237571}
- 223: {fileID: 1502237570}
- 114: {fileID: 1502237569}
- 114: {fileID: 1502237568}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1502237568
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1502237567}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1301386320, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &1502237569
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1502237567}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
--- !u!223 &1502237570
Canvas:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1502237567}
m_Enabled: 1
serializedVersion: 2
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingLayerID: 0
m_SortingOrder: 0
--- !u!224 &1502237571
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1502237567}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 432530562}
- {fileID: 1646839690}
m_Father: {fileID: 0}
m_RootOrder: 1
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!1 &1646839689
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 1646839690}
m_Layer: 5
m_Name: LisenceText
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1646839690
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1646839689}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 38156657}
- {fileID: 155392643}
m_Father: {fileID: 1502237571}
m_RootOrder: 1
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -25}
m_SizeDelta: {x: -40, y: -90}
m_Pivot: {x: .5, y: .5}
--- !u!1 &1787239744
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1787239749}
- 20: {fileID: 1787239748}
- 92: {fileID: 1787239747}
- 124: {fileID: 1787239746}
- 81: {fileID: 1787239745}
- 114: {fileID: 1787239750}
m_Layer: 0
m_Name: Main Camera
m_TagString: MainCamera
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!81 &1787239745
AudioListener:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1787239744}
m_Enabled: 1
--- !u!124 &1787239746
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1787239744}
m_Enabled: 1
--- !u!92 &1787239747
Behaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1787239744}
m_Enabled: 1
--- !u!20 &1787239748
Camera:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1787239744}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
near clip plane: .300000012
far clip plane: 1000
field of view: 60
orthographic: 0
orthographic size: 5
m_Depth: -1
m_CullingMask:
serializedVersion: 2
m_Bits: 4294967295
m_RenderingPath: -1
m_TargetTexture: {fileID: 0}
m_TargetDisplay: 0
m_HDR: 0
m_OcclusionCulling: 1
m_StereoConvergence: 10
m_StereoSeparation: .0219999999
--- !u!4 &1787239749
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1787239744}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 1, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &1787239750
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1787239744}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e8acd81474de8324fa0d60f7399ebdd0, type: 3}
m_Name:
m_EditorClassIdentifier:

Просмотреть файл

@ -1,52 +0,0 @@
using UnityEngine;
using System.Collections;
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
namespace AVProWithOpenCVForUnityExample
{
public class AVProWithOpenCVForUnityExample : MonoBehaviour
{
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
public void OnShowLicenseButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("ShowLicense");
#else
Application.LoadLevel ("ShowLicense");
#endif
}
public void OnGetReadableTextureExample ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("GetReadableTextureExample");
#else
Application.LoadLevel ("GetReadableTextureExample");
#endif
}
public void OnExtractFrameExample ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("ExtractFrameExample");
#else
Application.LoadLevel ("ExtractFrameExample");
#endif
}
}
}

Просмотреть файл

@ -1,292 +0,0 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
using RenderHeads.Media.AVProVideo;
using OpenCVForUnity;
namespace AVProWithOpenCVForUnityExample
{
public class ExtractFrameExample : MonoBehaviour
{
private const int NumFrames = 16;
public bool _accurateSeek = false;
public int _timeoutMs = 250;
private float _timeStepSeconds;
private int _frameIndex = -1;
/// <summary>
/// The media player.
/// </summary>
public MediaPlayer mediaPlayer;
/// <summary>
/// The target texture.
/// </summary>
Texture2D targetTexture;
/// <summary>
/// The texture.
/// </summary>
Texture2D texture;
/// <summary>
/// The colors.
/// </summary>
Color32[] colors;
/// <summary>
/// The rgba mat.
/// </summary>
Mat rgbaMat;
/// <summary>
/// The m sepia kernel.
/// </summary>
Mat mSepiaKernel;
/// <summary>
/// The m size0.
/// </summary>
Size mSize0;
/// <summary>
/// The m intermediate mat.
/// </summary>
Mat mIntermediateMat;
public enum modeType
{
original,
sepia,
pixelize,
}
/// <summary>
/// The mode.
/// </summary>
modeType mode;
/// <summary>
/// The original mode toggle.
/// </summary>
public Toggle originalModeToggle;
/// <summary>
/// The sepia mode toggle.
/// </summary>
public Toggle sepiaModeToggle;
/// <summary>
/// The pixelize mode toggle.
/// </summary>
public Toggle pixelizeModeToggle;
// Use this for initialization
void Start ()
{
if (originalModeToggle.isOn) {
mode = modeType.original;
}
if (sepiaModeToggle.isOn) {
mode = modeType.sepia;
}
if (pixelizeModeToggle.isOn) {
mode = modeType.pixelize;
}
// sepia
mSepiaKernel = new Mat (4, 4, CvType.CV_32F);
mSepiaKernel.put (0, 0, /* R */0.189f, 0.769f, 0.393f, 0f);
mSepiaKernel.put (1, 0, /* G */0.168f, 0.686f, 0.349f, 0f);
mSepiaKernel.put (2, 0, /* B */0.131f, 0.534f, 0.272f, 0f);
mSepiaKernel.put (3, 0, /* A */0.000f, 0.000f, 0.000f, 1f);
// pixelize
mIntermediateMat = new Mat ();
mSize0 = new Size ();
mediaPlayer.Events.AddListener (OnVideoEvent);
}
// Update is called once per frame
void Update ()
{
if (texture != null) {
//Convert AVPro's Texture to Texture2D
float timeSeconds = _frameIndex * _timeStepSeconds;
mediaPlayer.ExtractFrame (targetTexture, timeSeconds, _accurateSeek, _timeoutMs);
//Convert Texture2D to Mat
Utils.texture2DToMat (targetTexture, rgbaMat);
if (mode == modeType.original) {
} else if (mode == modeType.sepia) {
Core.transform (rgbaMat, rgbaMat, mSepiaKernel);
} else if (mode == modeType.pixelize) {
Imgproc.resize (rgbaMat, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
Imgproc.resize (mIntermediateMat, rgbaMat, rgbaMat.size (), 0.0, 0.0, Imgproc.INTER_NEAREST);
}
Imgproc.putText (rgbaMat, "AVPro With OpenCV for Unity Example", new Point (50, rgbaMat.rows () / 2), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar (255, 0, 0, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText (rgbaMat, "ExtractFrame: " + timeSeconds, new Point (50, rgbaMat.rows () / 2 + 60), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar (0, 0, 255, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText (rgbaMat, "W:" + rgbaMat.width () + " H:" + rgbaMat.height () + " SO:" + Screen.orientation, new Point (5, rgbaMat.rows () - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar (255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
//Convert Mat to Texture2D
Utils.matToTexture2D (rgbaMat, texture, colors);
}
}
// Callback function to handle events
public void OnVideoEvent (MediaPlayer mp, MediaPlayerEvent.EventType et,
ErrorCode errorCode)
{
switch (et) {
case MediaPlayerEvent.EventType.ReadyToPlay:
mediaPlayer.Control.Play ();
mediaPlayer.Control.Pause ();
break;
case MediaPlayerEvent.EventType.FirstFrameReady:
Debug.Log ("First frame ready");
OnNewMediaReady ();
break;
case MediaPlayerEvent.EventType.FinishedPlaying:
mediaPlayer.Control.Rewind ();
break;
}
Debug.Log ("Event: " + et.ToString ());
}
/// <summary>
/// Raises the new media ready event.
/// </summary>
private void OnNewMediaReady ()
{
IMediaInfo info = mediaPlayer.Info;
Debug.Log ("GetVideoWidth " + info.GetVideoWidth () + " GetVideoHeight() " + info.GetVideoHeight ());
// Create a texture the same resolution as our video
if (targetTexture != null) {
Texture2D.Destroy (targetTexture);
targetTexture = null;
}
if (texture != null) {
Texture2D.Destroy (texture);
texture = null;
}
targetTexture = new Texture2D (info.GetVideoWidth (), info.GetVideoHeight (), TextureFormat.ARGB32, false);
texture = new Texture2D (info.GetVideoWidth (), info.GetVideoHeight (), TextureFormat.RGBA32, false);
colors = new Color32[texture.width * texture.height];
rgbaMat = new Mat (texture.height, texture.width, CvType.CV_8UC4);
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
_timeStepSeconds = (mediaPlayer.Info.GetDurationMs () / 1000f) / (float)NumFrames;
_frameIndex = Random.Range (0, NumFrames);
}
/// <summary>
/// Raises the destroy event.
/// </summary>
void OnDestroy ()
{
if (targetTexture != null) {
Texture2D.Destroy (targetTexture);
targetTexture = null;
}
if (texture != null) {
Texture2D.Destroy (texture);
texture = null;
}
if (mSepiaKernel != null) {
mSepiaKernel.Dispose ();
mSepiaKernel = null;
}
if (mIntermediateMat != null) {
mIntermediateMat.Dispose ();
mIntermediateMat = null;
}
}
/// <summary>
/// Raises the back button event.
/// </summary>
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("AVProWithOpenCVForUnityExample");
#else
Application.LoadLevel ("AVProWithOpenCVForUnityExample");
#endif
}
/// <summary>
/// Raises the original mode toggle event.
/// </summary>
public void OnOriginalModeToggle ()
{
if (originalModeToggle.isOn) {
mode = modeType.original;
}
}
/// <summary>
/// Raises the sepia mode toggle event.
/// </summary>
public void OnSepiaModeToggle ()
{
if (sepiaModeToggle.isOn) {
mode = modeType.sepia;
}
}
/// <summary>
/// Raises the pixelize mode toggle event.
/// </summary>
public void OnPixelizeModeToggle ()
{
if (pixelizeModeToggle.isOn) {
mode = modeType.pixelize;
}
}
}
}

Просмотреть файл

@ -1,279 +0,0 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using OpenCVForUnity.CoreModule;
using OpenCVForUnity.ImgprocModule;
using OpenCVForUnity.UnityUtils;
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
using RenderHeads.Media.AVProVideo;
using OpenCVForUnity;
namespace AVProWithOpenCVForUnityExample
{
public class GetReadableTextureExample : MonoBehaviour
{
/// <summary>
/// The media player.
/// </summary>
public MediaPlayer mediaPlayer;
/// <summary>
/// The target texture.
/// </summary>
Texture2D targetTexture;
/// <summary>
/// The texture.
/// </summary>
Texture2D texture;
/// <summary>
/// The colors.
/// </summary>
Color32[] colors;
/// <summary>
/// The rgba mat.
/// </summary>
Mat rgbaMat;
/// <summary>
/// The m sepia kernel.
/// </summary>
Mat mSepiaKernel;
/// <summary>
/// The m size0.
/// </summary>
Size mSize0;
/// <summary>
/// The m intermediate mat.
/// </summary>
Mat mIntermediateMat;
public enum modeType
{
original,
sepia,
pixelize,
}
/// <summary>
/// The mode.
/// </summary>
modeType mode;
/// <summary>
/// The original mode toggle.
/// </summary>
public Toggle originalModeToggle;
/// <summary>
/// The sepia mode toggle.
/// </summary>
public Toggle sepiaModeToggle;
/// <summary>
/// The pixelize mode toggle.
/// </summary>
public Toggle pixelizeModeToggle;
// Use this for initialization
void Start ()
{
if (originalModeToggle.isOn) {
mode = modeType.original;
}
if (sepiaModeToggle.isOn) {
mode = modeType.sepia;
}
if (pixelizeModeToggle.isOn) {
mode = modeType.pixelize;
}
// sepia
mSepiaKernel = new Mat (4, 4, CvType.CV_32F);
mSepiaKernel.put (0, 0, /* R */0.189f, 0.769f, 0.393f, 0f);
mSepiaKernel.put (1, 0, /* G */0.168f, 0.686f, 0.349f, 0f);
mSepiaKernel.put (2, 0, /* B */0.131f, 0.534f, 0.272f, 0f);
mSepiaKernel.put (3, 0, /* A */0.000f, 0.000f, 0.000f, 1f);
// pixelize
mIntermediateMat = new Mat ();
mSize0 = new Size ();
mediaPlayer.Events.AddListener (OnVideoEvent);
}
// Update is called once per frame
void Update ()
{
if (texture != null) {
//Convert AVPro's Texture to Texture2D
Helper.GetReadableTexture (mediaPlayer.TextureProducer.GetTexture (), mediaPlayer.TextureProducer.RequiresVerticalFlip (), targetTexture);
//Convert Texture2D to Mat
Utils.texture2DToMat (targetTexture, rgbaMat);
if (mode == modeType.original) {
} else if (mode == modeType.sepia) {
Core.transform (rgbaMat, rgbaMat, mSepiaKernel);
} else if (mode == modeType.pixelize) {
Imgproc.resize (rgbaMat, mIntermediateMat, mSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
Imgproc.resize (mIntermediateMat, rgbaMat, rgbaMat.size (), 0.0, 0.0, Imgproc.INTER_NEAREST);
}
Imgproc.putText (rgbaMat, "AVPro With OpenCV for Unity Example", new Point (50, rgbaMat.rows () / 2), Imgproc.FONT_HERSHEY_SIMPLEX, 2.0, new Scalar (255, 0, 0, 255), 5, Imgproc.LINE_AA, false);
Imgproc.putText (rgbaMat, "W:" + rgbaMat.width () + " H:" + rgbaMat.height () + " SO:" + Screen.orientation, new Point (5, rgbaMat.rows () - 10), Imgproc.FONT_HERSHEY_SIMPLEX, 1.0, new Scalar (255, 255, 255, 255), 2, Imgproc.LINE_AA, false);
//Convert Mat to Texture2D
Utils.matToTexture2D (rgbaMat, texture, colors);
}
}
// Callback function to handle events
public void OnVideoEvent (MediaPlayer mp, MediaPlayerEvent.EventType et,
ErrorCode errorCode)
{
switch (et) {
case MediaPlayerEvent.EventType.ReadyToPlay:
mediaPlayer.Control.Play ();
break;
case MediaPlayerEvent.EventType.FirstFrameReady:
Debug.Log ("First frame ready");
OnNewMediaReady ();
break;
case MediaPlayerEvent.EventType.FinishedPlaying:
mediaPlayer.Control.Rewind ();
break;
}
Debug.Log ("Event: " + et.ToString ());
}
/// <summary>
/// Raises the new media ready event.
/// </summary>
private void OnNewMediaReady ()
{
IMediaInfo info = mediaPlayer.Info;
Debug.Log ("GetVideoWidth " + info.GetVideoWidth () + " GetVideoHeight() " + info.GetVideoHeight ());
// Create a texture the same resolution as our video
if (targetTexture != null) {
Texture2D.Destroy (targetTexture);
targetTexture = null;
}
if (texture != null) {
Texture2D.Destroy (texture);
texture = null;
}
targetTexture = new Texture2D (info.GetVideoWidth (), info.GetVideoHeight (), TextureFormat.ARGB32, false);
texture = new Texture2D (info.GetVideoWidth (), info.GetVideoHeight (), TextureFormat.RGBA32, false);
colors = new Color32[texture.width * texture.height];
rgbaMat = new Mat (texture.height, texture.width, CvType.CV_8UC4);
gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
}
/// <summary>
/// Raises the destroy event.
/// </summary>
void OnDestroy ()
{
if (targetTexture != null) {
Texture2D.Destroy (targetTexture);
targetTexture = null;
}
if (texture != null) {
Texture2D.Destroy (texture);
texture = null;
}
if (mSepiaKernel != null) {
mSepiaKernel.Dispose ();
mSepiaKernel = null;
}
if (mIntermediateMat != null) {
mIntermediateMat.Dispose ();
mIntermediateMat = null;
}
}
/// <summary>
/// Raises the back button event.
/// </summary>
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("AVProWithOpenCVForUnityExample");
#else
Application.LoadLevel ("AVProWithOpenCVForUnityExample");
#endif
}
/// <summary>
/// Raises the original mode toggle event.
/// </summary>
public void OnOriginalModeToggle ()
{
if (originalModeToggle.isOn) {
mode = modeType.original;
}
}
/// <summary>
/// Raises the sepia mode toggle event.
/// </summary>
public void OnSepiaModeToggle ()
{
if (sepiaModeToggle.isOn) {
mode = modeType.sepia;
}
}
/// <summary>
/// Raises the pixelize mode toggle event.
/// </summary>
public void OnPixelizeModeToggle ()
{
if (pixelizeModeToggle.isOn) {
mode = modeType.pixelize;
}
}
}
}

Просмотреть файл

@ -1,34 +0,0 @@
using UnityEngine;
using System.Collections;
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
using UnityEngine.SceneManagement;
#endif
namespace AVProWithOpenCVForUnityExample
{
public class ShowLicense : MonoBehaviour
{
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
}
public void OnBackButton ()
{
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
SceneManager.LoadScene ("AVProWithOpenCVForUnityExample");
#else
Application.LoadLevel ("AVProWithOpenCVForUnityExample");
#endif
}
}
}

Просмотреть файл

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d3b818f28800a7a408c688131a45a833
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,214 @@
using System.Collections.Generic;
using UnityEngine;
namespace AVProWithOpenCVForUnityExample
{
// v1.0.1
public class FpsMonitor : MonoBehaviour
{
int tick = 0;
float elapsed = 0;
float fps = 0;
public enum Alignment
{
LeftTop,
RightTop,
LeftBottom,
RightBottom,
}
public Alignment alignment = Alignment.RightTop;
const float GUI_WIDTH = 75f;
const float GUI_HEIGHT = 30f;
const float MARGIN_X = 10f;
const float MARGIN_Y = 10f;
const float INNER_X = 8f;
const float INNER_Y = 5f;
const float GUI_CONSOLE_HEIGHT = 50f;
public Vector2 offset = new Vector2(MARGIN_X, MARGIN_Y);
public bool boxVisible = true;
public float boxWidth = GUI_WIDTH;
public float boxHeight = GUI_HEIGHT;
public Vector2 padding = new Vector2(INNER_X, INNER_Y);
public float consoleHeight = GUI_CONSOLE_HEIGHT;
GUIStyle console_labelStyle;
float x, y;
Rect outer;
Rect inner;
float console_x, console_y;
Rect console_outer;
Rect console_inner;
int oldScrWidth;
int oldScrHeight;
Dictionary<string, string> outputDict = new Dictionary<string, string>();
protected string _consoleText = null;
public virtual string consoleText
{
get { return _consoleText; }
set
{
_consoleText = value;
toast_time = -1;
}
}
int toast_time = -1;
// Use this for initialization
void Start()
{
console_labelStyle = new GUIStyle();
console_labelStyle.fontSize = 32;
console_labelStyle.fontStyle = FontStyle.Normal;
console_labelStyle.wordWrap = true;
console_labelStyle.normal.textColor = Color.white;
oldScrWidth = Screen.width;
oldScrHeight = Screen.height;
LocateGUI();
}
// Update is called once per frame
void Update()
{
tick++;
elapsed += Time.deltaTime;
if (elapsed >= 1f)
{
fps = tick / elapsed;
tick = 0;
elapsed = 0;
}
if (toast_time > 0)
{
toast_time = toast_time - 1;
}
}
void OnGUI()
{
if (oldScrWidth != Screen.width || oldScrHeight != Screen.height)
{
LocateGUI();
}
oldScrWidth = Screen.width;
oldScrHeight = Screen.height;
if (boxVisible)
{
GUI.Box(outer, "");
}
GUILayout.BeginArea(inner);
{
GUILayout.BeginVertical();
GUILayout.Label("fps : " + fps.ToString("F1"));
foreach (KeyValuePair<string, string> pair in outputDict)
{
GUILayout.Label(pair.Key + " : " + pair.Value);
}
GUILayout.EndVertical();
}
GUILayout.EndArea();
if (!string.IsNullOrEmpty(consoleText))
{
if (toast_time != 0) {
if (boxVisible)
{
GUI.Box(console_outer, "");
}
GUILayout.BeginArea(console_inner);
{
GUILayout.BeginVertical();
GUILayout.Label(consoleText, console_labelStyle);
GUILayout.EndVertical();
}
GUILayout.EndArea();
}
}
}
public void Add(string key, string value)
{
if (outputDict.ContainsKey(key))
{
outputDict[key] = value;
}
else
{
outputDict.Add(key, value);
}
}
public void Remove(string key)
{
outputDict.Remove(key);
}
public void Clear()
{
outputDict.Clear();
}
public void LocateGUI()
{
x = GetAlignedX(alignment, boxWidth);
y = GetAlignedY(alignment, boxHeight);
outer = new Rect(x, y, boxWidth, boxHeight);
inner = new Rect(x + padding.x, y + padding.y, boxWidth, boxHeight);
console_x = GetAlignedX(Alignment.LeftBottom, Screen.width);
console_y = GetAlignedY(Alignment.LeftBottom, consoleHeight);
console_outer = new Rect(console_x, console_y, Screen.width - offset.x * 2, consoleHeight);
console_inner = new Rect(console_x + padding.x, console_y + padding.y, Screen.width - offset.x * 2 - padding.x, consoleHeight);
}
public void Toast(string message, int time = 120)
{
_consoleText = message;
toast_time = (time < 60) ? 60 : time;
}
float GetAlignedX(Alignment anchor, float w)
{
switch (anchor)
{
default:
case Alignment.LeftTop:
case Alignment.LeftBottom:
return offset.x;
case Alignment.RightTop:
case Alignment.RightBottom:
return Screen.width - w - offset.x;
}
}
float GetAlignedY(Alignment anchor, float h)
{
switch (anchor)
{
default:
case Alignment.LeftTop:
case Alignment.RightTop:
return offset.y;
case Alignment.LeftBottom:
case Alignment.RightBottom:
return Screen.height - h - offset.y;
}
}
}
}

Просмотреть файл

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b3afd8b9824360045957f5329d104d6d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Просмотреть файл

@ -0,0 +1,26 @@
using UnityEngine;
using UnityEngine.SceneManagement;
namespace AVProWithOpenCVForUnityExample
{
public class ShowLicense : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void OnBackButton()
{
SceneManager.LoadScene("AVProWithOpenCVForUnityExample");
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,2 @@
fileFormatVersion: 1
guid: fd1a96e49a9d44bbdabee3e9edb3d529

Просмотреть файл

@ -0,0 +1,5 @@
fileFormatVersion: 2
guid: b1e363552644181419caa3e5db1c202e
folderAsset: yes
DefaultImporter:
userData:

Двоичный файл не отображается.

Просмотреть файл

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: eeac93a986e026742ab84f895e5df439
MovieImporter:
serializedVersion: 1
quality: .5
linearTexture: 0
userData:

Просмотреть файл

@ -1,20 +1,34 @@
AVPro With OpenCV for Unity Example
====================
Screen Shot
Overview
-----
![ScreenShot.PNG](ScreenShot.PNG)
This example shows how to convert AVProVideo and AVProLiveCamera texture to OpenCV Mat using AsyncGPUReadback.
- AVProVideoGetReadableTextureExample
- AVProVideoAsyncGPUReadbackExample
- AVProVideoExtractFrameExample
- AVProLiveCameraGetFrameAsColor32Example
- AVProLiveCameraAsyncGPUReadbackExample
Environment
-----
[OpenCVForUnity](https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088?aid=1011l4ehR) 2.1.0
[UnityPlugin-AVProVideo](https://assetstore.unity.com/packages/tools/video/avpro-video-56355?aid=1011l4ehR)-Latest-Trial 1.5.12
- Unity 2020.3.48f1+
[OpenCVForUnity](https://assetstore.unity.com/packages/tools/integration/opencv-for-unity-21088?aid=1011l4ehR) 2.5.9+
[UnityPlugin-AVProVideo](https://assetstore.unity.com/packages/tools/video/avpro-video-v3-core-desktop-edition-278895?aid=1011l4ehR) 2.9.3+ (Latest-Trial)
[UnityPlugin-AVProLiveCamera](https://assetstore.unity.com/packages/tools/video/avpro-live-camera-3683?aid=1011l4ehR) 2.9.3+ (Latest-Trial)
Setup
-----
* Create New Project. (AVProWithOpenCVForUnityExample)
* Import OpenCVForUnity2.3.3 from AssetStore
* Import UnityPlugin-AVProVideo-Latest-Trial.unitypackage
* Import AVProWithOpenCVForUnityExample.unitypackage
1. Download the latest release unitypackage. [AVProWithOpenCVForUnityExample.unitypackage](https://github.com/EnoxSoftware/AVProWithOpenCVForUnityExample/releases)
1. Create New Project. (AVProWithOpenCVForUnityExample)
1. Import OpenCVForUnity from AssetStore
1. Import UnityPlugin-AVProVideo-Latest-Trial.unitypackage
1. Import UnityPlugin-AVProLiveCamera-Latest-Trial.unitypackage
1. Import AVProWithOpenCVForUnityExample.unitypackage
1. Add the "Assets/AVProWithOpenCVForUnityExample/*.unity" files to the "Scenes In Build" list in the "Build Settings" window.
1. Build and Deploy.
Screen Shot
-----
![ScreenShot.PNG](ScreenShot.PNG)