资源简介
贝叶斯抠图的C++源代码,用到了openCV,计算机视觉

代码片段和文件信息
#include “gui.h“
#include “matting.h“
// stroke type
#define _strokeu 2
#define _strokefg 1
#define _strokebg 0
// stroke color
int _strokeColor[] ={0 255 128};
// stroke
#define _swmin 1
#define _swmax 40
#define _swdefault 10
// state
#define _drawing 1
#define _idle 0
// global variable
static int stroketype = _strokefg;
static int strokewidth;
static int lastx lasty state;
IplImage *img_gui *usr *flashOnlyImg_gui;
void DrawStroke(int evt int x int y int flags void *param)
{
CvScalar color = cvScalar( _strokeColor[stroketype]);
if( evt == CV_EVENT_LBUTTONDOWN )
{
state = _drawing;
lastx = x lasty = y;
}
else if( evt == CV_EVENT_LBUTTONUP )
{
state = _idle;
cvLine( usr cvPoint(lastx lasty) cvPoint(xy) color strokewidth);
}
else if( evt == CV_EVENT_MOUSEMOVE && state == _drawing )
{
cvLine( usr cvPoint(lastx lasty) cvPoint(xy) color strokewidth);
lastx = x lasty = y;
}
return;
}
void RenderMsg( IplImage *display)
{
char msg[1000];
CvFont font = cvFont( 1.0 1);
cvInitFont( &font CV_FONT_HERSHEY_PLAIN 1.5 1.5 0 2 CV_AA);
if( stroketype == _strokebg)
cvPutText( display “Stroke: +background“ cvPoint( 0 display->height - 1) &font CV_RGB( 255 255 255));
else if( stroketype == _strokefg)
cvPutText( display “Stroke: +foreground“ cvPoint( 0 display->height - 1) &font CV_RGB( 255 255 255));
else if( stroketype == _strokeu)
cvPutText( display “Stroke: eraser“ cvPoint( 0 display->height - 1) &font CV_RGB( 255 255 255));
sprintf( msg “brush size: %3d“ strokewidth);
cvPutText( display msg cvPoint( 0 20) &font CV_RGB( 0 255 0));
return;
}
void initializeGUI(IplImage *img IplImage *trimap IplImage *flashOnlyImg)
{
img_gui = cvCloneImage( img );
usr = cvCloneImage( trimap );
printf(“----------------starting trimap drawing gui----------------\n“);
printf(“press ‘q‘ to leave\n“);
printf(“press ‘w‘ to change stroke type\n“);
printf(“press ‘a‘ to increase stroke width\n“);
printf(“press ‘d‘ to decrease stroke width\n“);
if(flashOnlyImg!=NULL)
{
flashOnlyImg_gui = cvCloneImage( flashOnlyImg );
printf(“press ‘u‘ to increase threshold in auto-generating trimap\n“);
printf(“press ‘i‘ to decrease threshold in auto-generating trimap\n“);
}
}
void run()
{
int key;
IplImage *mask = cvCreateImage( cvGetSize(img_gui) 8 1 );
IplImage *display = cvCreateImage( cvGetSize(img_gui) 8 3 );
IplImage *fgcolor = cvCloneImage( img_gui) *bgcolor = cvCloneImage( img_gui);
cvSet( fgcolor cvScalar( 255 0 0)) cvSet( bgcolor cvScalar( 0 255 255));
// gui
int swmin = _swmin;
int swmax = max( max( img_gui->width img_gui->height) / 8 1);
int swstep = max( min( img_gui->width img_gui->height) / 100 1);
int swdefault = min( max( min( img_gui->width img_gui->height) / 32 swmin) swmax);
strokewidth = swdefaul
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-01-01 18:55 matting\
目录 0 2012-01-01 18:55 matting\matting\
文件 886 2011-04-18 14:15 matting\matting.sln
文件 15360 2011-04-18 14:15 matting\matting.suo
文件 4847 2011-04-18 14:15 matting\matting\gui.cpp
文件 408 2011-04-18 14:15 matting\matting\gui.h
文件 11298 2011-04-18 14:15 matting\matting\main.cpp
文件 93737 2011-04-18 14:15 matting\matting\matting.cpp
文件 16225 2011-04-18 14:15 matting\matting\matting.h
文件 4703 2011-04-18 14:15 matting\matting\matting.vcproj
文件 7231 2011-04-18 14:15 matting\matting\solver.cpp
文件 1252 2011-04-18 14:15 matting\matting\solver.h
文件 83456 2011-04-18 14:15 matting\matting\Thumbs.db
文件 633 2011-04-18 14:15 matting\readme.txt
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 人脸识别(opencv_facedetect_v4l2)
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- 基于opencv的模板匹配代码
评论
共有 条评论