OpenCVForUnity案例汇总

Baiscs

一、Texture2DToMatExample

1.演示Texture2D和自定义Mat对象如何互相转换,并显示在一个Cube上面。分别用到Utils.texture2DToMat (imgTexture, imgMat)和Utils.matToTexture2D (imgMat, texture)方法。

二、WebCamTextureToMatExample

1.可以指定摄像头编号或名称,从而获取WebCamDevice对象和WebCamTexture对象;如果没有指定,则默认从后置摄像头获取。

2.WebCamDevice对象创建时,可以指定宽度,高度,帧率。

3.Update中,将WebCamDevice对象先缓存到自定义Mat对象中,再从Mat转存至Texture2D对象中。分别用到Utils.webCamTextureToMat (webCamTexture, rgbaMat, colors)和Utils.matToTexture2D (rgbaMat, texture, colors)两个方法。

三、WebCamTextureToMatHelperExample

四、MatBasicProcessingExample

演示Core工具类对Mat对象的操作汇总。

五、Utils_GetFilePathExample

演示从StreamingAssets文件夹中获取指定文件名的文件路径。

Advanced

一、ComicFilterExample

动漫风格滤镜

二、GreenScreenExample

绿幕抠像

三、HandPoseEstimationExample

四、MultiObjectTrackingBasedOnColorExample

根据颜色区分多个物体

五、PolygonFilterExample

多边形风格滤镜

六、AlphaBlendingExample

前两张图片根据第三张图片的Alpha值,混合成第四张图片。

七、MatToTextureInRenderThreadExample

主要用到Utils.matToTextureInRenderThread (rgbaMat, texture)方法,并且在每一帧结束时调用。

Main Modules

一、core:PCAExample

1.识别几个物体轮廓并用红线描边。

2.用PCA算法计算单个物体的主成方向,并用青色箭头指示。

二、imgproc:CircleDetectionExample

三、imgproc:ConnectedComponentsExample

1.识别

四、imgproc:ConvexHullExample

1.主要用到int total = Imgproc.connectedComponentsWithStats (srcMat, labels, stats, centroids)方法,共识别到包括背景在内的四种轮廓。

2.在后三个轮廓上:①draw centroids中心点用红色标记②draw index of label用黄色数字标签③draw rectangle绘制绿色矩形轮廓④draw labels随机填充轮廓范围。

五、imgproc:DrawingExample

1.在图片上绘制各种图像。

2.Imgproc.line (imgMat, new Point (50, 50), new Point (400, 105), new Scalar (0, 0, 200), 3)--绘制蓝色线

3.Imgproc.rectangle (imgMat, new Point (150, 200), new Point (300, 300), new Scalar (0, 200, 0), 5)--绘制绿色矩形

4.Imgproc.circle (imgMat, new Point (500, 300), 80, new Scalar (200, 0, 0), 1)--绘制红色圆圈

5.Imgproc.arrowedLine (imgMat, new Point (100, 500), new Point (550, 350), new Scalar (255, 255, 0), 4, Imgproc.LINE_8, 0, 0.1)--绘制黄色箭头

6.Imgproc.ellipse (imgMat, new Point (200, 400), new Size (80, 150), angle, angle - 200, angle + 100, new Scalar (255, 255, 255), -1)--绘制弧形填充区域

7.Imgproc.putText (imgMat, "OpenCV", new Point (50, 50), face [0], 1.2, new Scalar (0, 0, 200), 2, Imgproc.LINE_AA, false)--绘制蓝色字体

六、imgproc:GrabCutExample

1.利用遮罩图“lena_grabcut_mask”对原始图片“lena”进行抠像。

七、imgproc:HoughLinesPExample

1.Imgproc.HoughLinesP (grayMat, lines, 1, Mathf.PI / 180, 50, 50, 10)--检测直线

八、imgproc:MatchShapesExample

1.Imgproc.findContours (srcMat, srcContours, srcHierarchy, Imgproc.RETR_CCOMP, Imgproc.CHAIN_APPROX_NONE)--识别轮廓数目

2. ①用Imgproc.drawContours (dstMat, srcContours, i, new Scalar (255, 0, 0), 2, 8, srcHierarchy, 0, new Point ())绘制红色轮廓线②Imgproc.circle (dstMat, point, 5, new Scalar (0, 0, 255), -1)绘制蓝色轮廓中心点③Imgproc.putText (dstMat, " " + returnVal, point, Imgproc.FONT_HERSHEY_SIMPLEX, 0.4, new Scalar (0, 255, 0), 1, Imgproc.LINE_AA, false)绘制绿色误差

九、imgproc:MatchTemplateExample

1.Imgproc.matchTemplate (imgMat, tempMat, result, match_method)--原图匹配指定的区域图。

十、imgproc:ThresholdExample

1.Imgproc.threshold (imgMat, imgMat, 0, 255, Imgproc.THRESH_BINARY | Imgproc.THRESH_OTSU)

十一、imgproc:WrapPerspectiveExample

1.Mat perspectiveTransform = Imgproc.getPerspectiveTransform (src_mat, dst_mat)--生成透视效果

十二、videoio:VideoCaptureExample

用于播放mjpeg格式的视频

十三、videoio:VideoWriterExample

1.演示从屏幕录制视频并存储为avi格式,可以播放已录制好的视频。

十四、video:BackgroundSubtractorMOG2Example

1.蓝色背景抠像

十五、video:CamShiftExample

1.根据四个点位,确定追踪对象。

十六、video:KalmanFilterExample

1.追踪鼠标位置,绘制轨迹。

十七、video:OpticalFlowExample

1.实时从摄像机画面,获取光斑。

十八、calib3d:StereoBMExample

1.根据左右眼两张图片获取图像深度信息。

十九、features2d:Feature2DExample

 

二十、features2d:MSERExample

 

二十一、objdetect:FaceDetectionExample

 

二十二、dnn:MobileNetSSDExample

 

二十三、dnn:MobileNetSSDWebCamTextureExample

 

二十四、dnn:OpenPoseExample

 

二十五、dnn:ResnetSSDFaceDetectionExample

 

二十六、dnn:TensorFlowWebCamTextureExample

 

二十七、dnn:YoloObjectDetectionExample

 

二十八、dnn:YoloObjectDetectionWebCamTextureExample

 

二十九、ml:SVMExample

 

三十、photo:InpaintExample

 

三十一、photo:SeamlessCloneExample

 

Contrib modules

一、aruco:ArUcoExample

 

二、aruco:ArUcoWebCamTextureExample

 

三、aruco:ArUcoCreateMarkerExample

 

四、aruco:ArUcoCameraCalibrationExample

 

五、face:FaceMarkExample

 

六、face:FaceRecognizerExample

 

七、plot:PlotExample

 

八、shape:ThinPlateSplineShapeTransformerExample

 

九、text:TextDetectionExample

 

十、text:TextRecognitionExample

 

十一、tracking:TrackingExample

 

Works with Unity Cloud Build iOS & Android support Windows10 UWP support WebGL support Win & Mac & Linux Standalone support Preview support in the Editor OpenCV for Unity is an Assets Plugin for using OpenCV 3.4.2 from within Unity. Official Site | ExampleCode | Android Demo WebGL Demo | Tutorial & Demo Video | Forum | API Reference | Support Modules Features: - Since this package is a clone of OpenCV Java, you are able to use the same API as OpenCV Java 3.4.2 (link). - You can image processing in real-time by using the WebCamTexture capabilities of Unity. (real-time face detection works smoothly on iPhone 5) - Provides a method to interconversion of Unity's Texture2D and OpenCV's Mat. - IDisposable is implemented in many classes.You can manage the resources with the “using” statement. - Examples of integration with other publisher assets are available.(e.g. PlayMaker, NatCam, NatCorder) ExampleCode using OpenCV for Unity is available. MarkerBased AR Example MarkerLess AR Example FaceTracker Example FaceSwapper Example FaceMask Example RealTime FaceRecognition Example GoogleVR with OpenCV for Unity Example Kinect with OpenCV for Unity Example AVPro with OpenCV for Unity Example HoloLens with OpenCV for Unity Example PlayMakerActions for OpenCVforUnity NatCam with OpenCVForUnity Example NatCorder with OpenCVForUnity Example OpenCV for Unity uses OpenCV under 3-clause BSD License; see Third-Party Notices.txt file in package for details. System Requirements Build Win Standalone & Preview Editor : Windows 7 or later Build Mac Standalone & Preview Editor : OSX 10.9 or later
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值