Changed the name of asset project.("Sample" to "Example")
This commit is contained in:
Родитель
9217d19998
Коммит
a1b80db7a9
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aaa9f41313573a04d8663cfad0d3b57b
|
||||
folderAsset: yes
|
||||
timeCreated: 1429005236
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -4,14 +4,13 @@ using Windows.Kinect;
|
|||
|
||||
using OpenCVForUnity;
|
||||
|
||||
public class ColorFrameSample : MonoBehaviour
|
||||
public class ColorFrameExample : MonoBehaviour
|
||||
{
|
||||
|
||||
KinectSensor sensor;
|
||||
ColorFrameReader reader;
|
||||
Texture2D texture;
|
||||
byte[] data;
|
||||
|
||||
Mat rgbaMat;
|
||||
|
||||
public enum modeType
|
||||
|
@ -39,8 +38,6 @@ public class ColorFrameSample : MonoBehaviour
|
|||
Mat comicDstMat;
|
||||
byte[] comicGrayPixels;
|
||||
byte[] comicMaskPixels;
|
||||
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
|
@ -92,7 +89,11 @@ public class ColorFrameSample : MonoBehaviour
|
|||
//create a striped background.
|
||||
comicBgMat = new Mat (texture.height, texture.width, CvType.CV_8UC1, new Scalar (255));
|
||||
for (int i = 0; i < comicBgMat.rows ()*2.5f; i=i+4) {
|
||||
#if OPENCV_3
|
||||
Imgproc.line (comicBgMat, new Point (0, 0 + i), new Point (comicBgMat.cols (), -comicBgMat.cols () + i), new Scalar (0), 1);
|
||||
#else
|
||||
Core.line (comicBgMat, new Point (0, 0 + i), new Point (comicBgMat.cols (), -comicBgMat.cols () + i), new Scalar (0), 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
comicDstMat = new Mat (texture.height, texture.width, CvType.CV_8UC1);
|
||||
|
@ -118,7 +119,7 @@ public class ColorFrameSample : MonoBehaviour
|
|||
frame = null;
|
||||
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -126,21 +127,29 @@ public class ColorFrameSample : MonoBehaviour
|
|||
|
||||
|
||||
if (mode == modeType.original) {
|
||||
|
||||
Imgproc.putText (rgbaMat, "ORIGINAL MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
|
||||
#if OPENCV_3
|
||||
Imgproc.putText (rgbaMat, "ORIGINAL MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#else
|
||||
Core.putText (rgbaMat, "ORIGINAL MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#endif
|
||||
} else if (mode == modeType.sepia) {
|
||||
|
||||
Core.transform (rgbaMat, rgbaMat, sepiaKernel);
|
||||
|
||||
Imgproc.putText (rgbaMat, "SEPIA MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
|
||||
Core.transform (rgbaMat, rgbaMat, sepiaKernel);
|
||||
|
||||
#if OPENCV_3
|
||||
Imgproc.putText (rgbaMat, "SEPIA MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#else
|
||||
Core.putText (rgbaMat, "SEPIA MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#endif
|
||||
} else if (mode == modeType.pixelize) {
|
||||
Imgproc.resize (rgbaMat, pixelizeIntermediateMat, pixelizeSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
|
||||
Imgproc.resize (pixelizeIntermediateMat, rgbaMat, rgbaMat.size (), 0.0, 0.0, Imgproc.INTER_NEAREST);
|
||||
|
||||
Imgproc.putText (rgbaMat, "PIXELIZE MODE" + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
|
||||
#if OPENCV_3
|
||||
Imgproc.putText (rgbaMat, "PIXELIZE MODE" + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#else
|
||||
Core.putText (rgbaMat, "PIXELIZE MODE" + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#endif
|
||||
} else if (mode == modeType.comic) {
|
||||
Imgproc.cvtColor (rgbaMat, comicGrayMat, Imgproc.COLOR_RGBA2GRAY);
|
||||
|
||||
|
@ -189,8 +198,11 @@ public class ColorFrameSample : MonoBehaviour
|
|||
|
||||
Imgproc.cvtColor (comicDstMat, rgbaMat, Imgproc.COLOR_GRAY2RGBA);
|
||||
|
||||
Imgproc.putText (rgbaMat, "COMIC MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
|
||||
#if OPENCV_3
|
||||
Imgproc.putText (rgbaMat, "COMIC MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#else
|
||||
Core.putText (rgbaMat, "COMIC MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
Utils.matToTexture (rgbaMat, texture);
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c06ee39143195c741914fcffdc94d6be
|
||||
timeCreated: 1432814843
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -4,7 +4,7 @@ using Windows.Kinect;
|
|||
|
||||
using OpenCVForUnity;
|
||||
|
||||
public class MultiSourceFrameSample : MonoBehaviour
|
||||
public class MultiSourceFrameExample : MonoBehaviour
|
||||
{
|
||||
|
||||
KinectSensor sensor;
|
||||
|
@ -46,8 +46,6 @@ public class MultiSourceFrameSample : MonoBehaviour
|
|||
byte[] comicGrayPixels;
|
||||
byte[] comicMaskPixels;
|
||||
|
||||
|
||||
|
||||
void Start ()
|
||||
{
|
||||
sensor = KinectSensor.GetDefault ();
|
||||
|
@ -109,7 +107,11 @@ public class MultiSourceFrameSample : MonoBehaviour
|
|||
//create a striped background.
|
||||
comicBgMat = new Mat (texture.height, texture.width, CvType.CV_8UC1, new Scalar (255));
|
||||
for (int i = 0; i < comicBgMat.rows ()*2.5f; i=i+4) {
|
||||
#if OPENCV_3
|
||||
Imgproc.line (comicBgMat, new Point (0, 0 + i), new Point (comicBgMat.cols (), -comicBgMat.cols () + i), new Scalar (0), 1);
|
||||
#else
|
||||
Core.line (comicBgMat, new Point (0, 0 + i), new Point (comicBgMat.cols (), -comicBgMat.cols () + i), new Scalar (0), 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
comicDstMat = new Mat (texture.height, texture.width, CvType.CV_8UC1);
|
||||
|
@ -149,7 +151,7 @@ public class MultiSourceFrameSample : MonoBehaviour
|
|||
|
||||
frame = null;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -167,9 +169,7 @@ public class MultiSourceFrameSample : MonoBehaviour
|
|||
|
||||
int index = x + y * width;
|
||||
|
||||
int tmp = ((int)depthSpacePoints [index].X + (int)depthSpacePoints [index].Y * depthWidth < 0) ? 0 : (int)depthSpacePoints [index].X + (int)depthSpacePoints [index].Y * depthWidth;
|
||||
|
||||
if (bodyIndexData [tmp] == 255) {
|
||||
if (bodyIndexData [(int)depthSpacePoints [index].X + (int)depthSpacePoints [index].Y * depthWidth] == 255) {
|
||||
maskData [index] = 0;
|
||||
} else {
|
||||
maskData [index] = 255;
|
||||
|
@ -182,25 +182,34 @@ public class MultiSourceFrameSample : MonoBehaviour
|
|||
if (mode == modeType.original) {
|
||||
|
||||
rgbaMat.copyTo (outputMat, maskMat);
|
||||
|
||||
Imgproc.putText (outputMat, "ORIGINAL MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
|
||||
|
||||
#if OPENCV_3
|
||||
Imgproc.putText (outputMat, "ORIGINAL MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#else
|
||||
Core.putText (outputMat, "ORIGINAL MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#endif
|
||||
} else if (mode == modeType.sepia) {
|
||||
|
||||
Core.transform (rgbaMat, rgbaMat, sepiaKernel);
|
||||
|
||||
rgbaMat.copyTo (outputMat, maskMat);
|
||||
|
||||
Imgproc.putText (outputMat, "SEPIA MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
|
||||
|
||||
#if OPENCV_3
|
||||
Imgproc.putText (outputMat, "SEPIA MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#else
|
||||
Core.putText (outputMat, "SEPIA MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#endif
|
||||
} else if (mode == modeType.pixelize) {
|
||||
Imgproc.resize (rgbaMat, pixelizeIntermediateMat, pixelizeSize0, 0.1, 0.1, Imgproc.INTER_NEAREST);
|
||||
Imgproc.resize (pixelizeIntermediateMat, rgbaMat, rgbaMat.size (), 0.0, 0.0, Imgproc.INTER_NEAREST);
|
||||
|
||||
rgbaMat.copyTo (outputMat, maskMat);
|
||||
|
||||
Imgproc.putText (outputMat, "PIXELIZE MODE" + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
|
||||
#if OPENCV_3
|
||||
Imgproc.putText (outputMat, "PIXELIZE MODE" + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#else
|
||||
Core.putText (outputMat, "PIXELIZE MODE" + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#endif
|
||||
} else if (mode == modeType.comic) {
|
||||
Imgproc.cvtColor (rgbaMat, comicGrayMat, Imgproc.COLOR_RGBA2GRAY);
|
||||
|
||||
|
@ -252,8 +261,11 @@ public class MultiSourceFrameSample : MonoBehaviour
|
|||
|
||||
rgbaMat.copyTo (outputMat, maskMat);
|
||||
|
||||
Imgproc.putText (outputMat, "COMIC MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Imgproc.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
|
||||
#if OPENCV_3
|
||||
Imgproc.putText (outputMat, "COMIC MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#else
|
||||
Core.putText (outputMat, "COMIC MODE " + texture.width + "x" + texture.height, new Point (5, texture.height - 5), Core.FONT_HERSHEY_PLAIN, 4.0, new Scalar (255, 0, 0, 255), 3);
|
||||
#endif
|
||||
}
|
||||
|
||||
Utils.matToTexture (outputMat, texture);
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d0b3d0bb797e6dd498335570842ddf08
|
||||
timeCreated: 1432814548
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 492d8e8d16e220b41b61526b0487f45c
|
||||
timeCreated: 1429005447
|
||||
licenseType: Pro
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Двоичный файл не отображается.
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 93b638f38a09d4b4d8fd58aa67458a54
|
||||
timeCreated: 1429005503
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,4 +1,4 @@
|
|||
Kinect with OpenCV for Unity Sample
|
||||
Kinect with OpenCV for Unity Example
|
||||
====================
|
||||
|
||||
Demo Video
|
||||
|
@ -17,12 +17,12 @@ Setup
|
|||
* Import OpenCVForUnity2.0.0 from AssetStore
|
||||
|
||||
|
||||
Samples
|
||||
Examples
|
||||
-----
|
||||
**[ColorFrameSample.cs](ColorFrameSample.cs)**
|
||||
**[ColorFrameExample.cs](/Assets/KinectOpenCVForUnityExample/ColorFrameExample.cs)**
|
||||
Converts ColorFrame acquired from "Kinect" to Mat of "OpenCV", perform image processing.
|
||||
|
||||
**[MultiSourceFrameSample.cs](MultiSourceFrameSample.cs)**
|
||||
**[MultiSourceFrameExample.cs](/Assets/KinectOpenCVForUnityExample/MultiSourceFrameExample.cs)**
|
||||
Converts BodyIndexFrame acquired from "Kinect" to Mat of "OpenCV", perform image processing only person.
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче