资源简介
使用OpenCV对摄像头中的图像进行卡通画处理,基于OpenCV2.4.2,VS2010,环境需要自己配置~
博客描述http://blog.csdn.net/guoming0000/article/details/8290146
本人blog:http://ilovecode.cn
代码片段和文件信息
/*****************************************************************************
* cartoon.cpp
* Create a cartoon-like or painting-like image filter.
******************************************************************************
* by Shervin Emami 5th Dec 2012 (shervin.emami@gmail.com)
* http://www.shervinemami.info/
******************************************************************************
* Ch1 of the book “Mastering OpenCV with Practical Computer Vision Projects“
* Copyright Packt Publishing 2012.
* http://www.packtpub.com/cool-projects-with-opencv/book
*****************************************************************************/
#include “stdafx.h“
#include “cartoon.h“
#include “ImageUtils.h“ // Handy functions for debugging OpenCV images by Shervin Emami.
// Convert the given photo into a cartoon-like or painting-like image.
// Set sketchMode to true if you want a line drawing instead of a painting.
// Set alienMode to true if you want alien skin instead of human.
// Set evilMode to true if you want an “evil“ character instead of a “good“ character.
// Set debugType to 1 to show where skin color is taken from and 2 to show the skin mask in a new window (for desktop).
void cartoonifyImage(Mat srcColor Mat dst bool sketchMode bool alienMode bool evilMode int debugType)
{
// Convert from BGR color to Grayscale
Mat srcGray;
cvtColor(srcColor srcGray CV_BGR2GRAY);
// Remove the pixel noise with a good Median filter before we start detecting edges.
medianBlur(srcGray srcGray 7);
Size size = srcColor.size();
Mat mask = Mat(size CV_8U);
Mat edges = Mat(size CV_8U);
if (!evilMode) {
// Generate a nice edge mask similar to a pencil line drawing.
Laplacian(srcGray edges CV_8U 5);
threshold(edges mask 80 255 THRESH_BINARY_INV);
// Mobile cameras usually have lots of noise so remove small
// dots of black noise from the black & white edge mask.
removePepperNoise(mask);
}
else {
// Evil mode making everything look like a scary bad guy.
// (Where “srcGray“ is the original grayscale image plus a medianBlur of size 7x7).
Mat edges2;
Scharr(srcGray edges CV_8U 1 0);
Scharr(srcGray edges2 CV_8U 1 0 -1);
edges += edges2;
threshold(edges mask 12 255 THRESH_BINARY_INV);
medianBlur(mask mask 3);
}
//imshow(“edges“ edges);
//imshow(“mask“ mask);
// For sketch mode we just need the mask!
if (sketchMode) {
// The output image has 3 channels not a single channel.
cvtColor(mask dst CV_GRAY2BGR);
return;
}
// Do the bilateral filtering at a shrunken scale since it
// runs so slowly but doesn‘t need full resolution for a good effect.
Size smallSize;
smallSize.width = size.width/2;
smallSize.height = size.height/2;
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 13859 2012-12-13 11:36 Cartoonifier\Cartoonifier\cartoon.cpp
文件 1677 2012-12-13 10:37 Cartoonifier\Cartoonifier\cartoon.h
文件 6562 2012-12-13 11:35 Cartoonifier\Cartoonifier\Cartoonifier.cpp
文件 5188 2012-12-13 11:54 Cartoonifier\Cartoonifier\Cartoonifier.vcxproj
文件 1686 2012-12-13 11:35 Cartoonifier\Cartoonifier\Cartoonifier.vcxproj.filters
文件 143 2012-12-13 11:33 Cartoonifier\Cartoonifier\Cartoonifier.vcxproj.user
文件 21322 2012-12-13 10:37 Cartoonifier\Cartoonifier\ImageUtils.h
文件 87477 2012-12-13 11:36 Cartoonifier\Cartoonifier\ImageUtils_0.7.cpp
文件 1588 2012-12-13 11:33 Cartoonifier\Cartoonifier\ReadMe.txt
文件 217 2012-12-13 11:33 Cartoonifier\Cartoonifier\stdafx.cpp
文件 233 2012-12-13 11:33 Cartoonifier\Cartoonifier\stdafx.h
文件 236 2012-12-13 11:33 Cartoonifier\Cartoonifier\targetver.h
文件 903 2012-12-13 11:33 Cartoonifier\Cartoonifier.sln
..A..H. 12288 2012-12-13 12:04 Cartoonifier\Cartoonifier.suo
文件 139264 2012-12-13 11:36 Cartoonifier\Debug\Cartoonifier.exe
目录 0 2012-12-13 12:07 Cartoonifier\Cartoonifier
目录 0 2012-12-13 12:07 Cartoonifier\Debug
目录 0 2012-12-13 12:07 Cartoonifier
----------- --------- ---------- ----- ----
292643 18
- 上一篇:网络爬虫爬取网页链接
- 下一篇:Qt之QWizard向导界面
相关资源
- 镜头选型计算公式
- 基于机器视觉的织物疵点检测系统
- flash射击类游戏
- 机器视觉霍夫圆检测识别木材死节O
- 软件工程方面的校园一卡通设计方案
- 炫酷3d立体卡通文字特效div+css
- 基于机器视觉的Delta机器人分拣系统算
- 复杂背景下文字分割程序_源代码
- 虚拟机linux和开发板网卡通信.pdf
- 机器视觉棋盘格标定板 CAD格式
- 无人驾驶汽车路径识别算法
- 机器人在ros下的KCF跟踪算法实现
- unity3D卡通女战士精细人物角色模型带
- Speed-Up Robust Features(SURF) 论文中文翻
- 机械手与机器视觉坐标系的转换
- halcon相机标定
- 机器视觉习题
- LABVIEW-机器视觉模块中文说明书
- 校园一卡通数据库设计
- halcon_17 深度学习
- 基于机器视觉的停车位检测技术的研
- 九点标定opencv+VS2015)
- 带有骨骼动画的人物模型真实的、卡
- Dobot 机械臂 机器视觉 坐标转换文档
- 基于机器视觉的水果外部品质检测系
- 机器视觉教程.txt
- Sun产品在西南交大校园一卡通工程中
- IC卡通用改密码程序
- 校园一卡通系统源代码
- 儿童卡通PPT模板.rar
评论
共有 条评论