一维二维码的提取、识别和产生
Mat cannyClone = Mat : :zeros(Size(gray.cols,gray.rows),gray.type());
Canny(gray,canny, 100, 255);
Mat element = getStructuringElement(MORPH_ELLIPSE,Size( 7, 3));
morphologyEx(canny,canny,CV_MOP_DILATE,element);
morphologyEx(canny,canny,CV_MOP_ERODE ,element);
imwrite( "canny.jpg",canny);
findContours(canny,contours,CV_RETR_TREE,CV_CHAIN_APPROX_NONE);
for ( int i = 0;i <contours.size();i ++)
{
int itmp = contourArea(contours[i]);
if (imaxcontour < itmp )
{
imax = i;
imaxcontour = itmp;
}
}
//找到轮廓的处理
Rect boundRect; //最小外接矩形
drawContours(cannyClone,contours,imax,Scalar( 255), - 1);
boundRect = boundingRect(Mat(contours[imax]));
Mat srcRoi = src(boundRect);
imwrite( "barcode.jpg",srcRoi);
MultiFormatReader mutiReader = new com.google.zxing.MultiFormatReader();
Bitmap img = (Bitmap)Bitmap.FromFile(opFilePath);
if (img == null)
return;
LuminanceSource ls = new RGBLuminanceSource(img, img.Width, img.Height);
BinaryBitmap bb = new BinaryBitmap( new com.google.zxing.common.HybridBinarizer(ls));
Result r = mutiReader.decode(bb);
tb.Text = r.Text;
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
最大轮廓和投影
最大轮廓和投影 最近非常多的用到了最大轮廓和投影运算。回想起来,这两种算法的确是属于非常常见的基础算法。这里加以总结和提取。 最大轮廓: 前提是图像经过了灰度和阈值处理,也可以直接处理canny的结果,有些时候需要预先经过色彩域的转换。最后得到的结果,应该是一个contour,当然可以采用一定的方法处理得到外接矩形。 //寻找最大的轮廓 vector <cv : :Point >FindBigestContour(Matsrc) { intimax = 0; //代表最大轮廓的序号 intimaxcontour = - 1; //代表最大轮廓的大小 std : :vector <std : :vector <cv : :Point >>contours; findContours(src,contours,CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE); for( inti = 0;i <contours.size();i ++) { intitmp =contourArea(contours...
- 下一篇
19_Android中图片处理原理篇,关于人脸识别网站,图片加载到内存,图片缩放,图片翻转倒置,网上撕衣服游戏案例编写
1 加载图片到内存 (1).数码相机照片特别是大于3m以上的,内存吃不消,会报OutOfMemoryError,若是想只显示原图片的1/8,可以通过BitmapFactory.Options来实现,具体代码如下: BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options(); bmpFactoryOptions.inSampleSize = 8; Bitmap bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions); imv.setImageBitmap(bmp); 如果图片太大,会出现的以下的问题: 2 根据当前屏幕分辨率的大小,加载图片 Display currentDisplay = getWindowManager().getDefaultDisplay(); int dw = currentDisplay.getWidth(); int dh = currentDisplay.getHeight(); BitmapFacto...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- Docker快速安装Oracle11G,搭建oracle11g学习环境
- Linux系统CentOS6、CentOS7手动修改IP地址
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- SpringBoot2整合Thymeleaf,官方推荐html解决方案
- CentOS关闭SELinux安全模块
- Eclipse初始化配置,告别卡顿、闪退、编译时间过长
- SpringBoot2整合Redis,开启缓存,提高访问速度
- CentOS8安装MyCat,轻松搞定数据库的读写分离、垂直分库、水平分库
- Hadoop3单机部署,实现最简伪集群