stretchdibits怎么用VC把bmp图片的数据信息还原为图片并显示
stretchdibits 时间:2021-01-10 阅读:(
)
StretchDIBits()函数中CONST VOID *lpBits是什么意思?
指向一个BYTE类型的数组,数组中记录了要拷贝到CBitmap对象的位值。
如何使用opencv获取已经灰度化二值化的一张黑色图片中的一个亮点的具体像素坐标
OpenCV
整个项目的结构图:
编写DetectFaceDemo.java,代码如下:
[java] view
plaincopyprint?
.njupt.zhb.test;
.opencv.core.Core;
.opencv.core.Mat;
.opencv.core.MatOfRect;
.opencv.core.Point;
.opencv.core.Rect;
.opencv.core.Scalar;
.opencv.highgui.Highgui;
.opencv.objdetect.CascadeClassifier;
//
// Detects faces in an image, draws boxes around them, and writes the results
// to "faceDetection.png".
//
public class DetectFaceDemo {
public void run() {
System.out.println("
Running DetectFaceDemo");
System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());
// Create a face detector from the cascade file in the resources
// directory.
//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());
//Mat image = Highgui.imread(getClass().getResource("lena.png").getPath());
//注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误
/*
* Detected 0 faces Writing faceDetection.png libpng warning: Image
* width is zero in IHDR libpng warning: Image height is zero in IHDR
* libpng error: Invalid IHDR data
*/
//因此,我们将第一个字符去掉
String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);
CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);
Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));
// Detect faces in the image.
// MatOfRect is a special container class for Rect.
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale(image, faceDetections);
System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));
// Draw a bounding box around each face.
for (Rect rect : faceDetections.toArray()) {
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));
}
// Save the visualized detection.
String filename = "faceDetection.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, image);
}
}
.njupt.zhb.test;
.opencv.core.Core;
.opencv.core.Mat;
.opencv.core.MatOfRect;
.opencv.core.Point;
.opencv.core.Rect;
.opencv.core.Scalar;
.opencv.highgui.Highgui;
.opencv.objdetect.CascadeClassifier;
//
// Detects faces in an image, draws boxes around them, and writes the results
// to "faceDetection.png".
//
public class DetectFaceDemo {
public void run() {
System.out.println("
Running DetectFaceDemo");
System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());
// Create a face detector from the cascade file in the resources
// directory.
//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());
//Mat image = Highgui.imread(getClass().getResource("lena.png").getPath());
//注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误
/*
* Detected 0 faces Writing faceDetection.png libpng warning: Image
* width is zero in IHDR libpng warning: Image height is zero in IHDR
* libpng error: Invalid IHDR data
*/
//因此,我们将第一个字符去掉
String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);
CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);
Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));
// Detect faces in the image.
// MatOfRect is a special container class for Rect.
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale(image, faceDetections);
System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));
// Draw a bounding box around each face.
for (Rect rect : faceDetections.toArray()) {
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));
}
// Save the visualized detection.
String filename = "faceDetection.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, image);
}
}
3.编写测试类:
[java] view
plaincopyprint?
.njupt.zhb.test;
public class TestMain {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
System.loadLibrary("opencv_java246");
new DetectFaceDemo().run();
}
}
//运行结果:
//Hello, OpenCV
//
//Running DetectFaceDemo
///E:/eclipse_Jee/workspace/JavaOpenCV246//njupt/zhb/test/lbpcascade_frontalface.xml
//Detected 8 faces
//Writing faceDetection.png
.njupt.zhb.test;
public class TestMain {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
System.loadLibrary("opencv_java246");
new DetectFaceDemo().run();
}
}
//运行结果:
//Hello, OpenCV
//
//Running DetectFaceDemo
///E:/eclipse_Jee/workspace/JavaOpenCV246//njupt/zhb/test/lbpcascade_frontalface.xml
//Detected 8 faces
//Writing faceDetection.pngDIB是什么格式
DIB设备无关位图文件,这是一种文件格式,是为了保证用某个应用程序创建的位图图形可以被其它应用程序装载或显示一样。
DIB的与设备无关性主要体现在以下两个方面:DIB的颜色模式与设备无关。
例如,一个256色的DIB即可以在真彩色显示模式下使用,也可以在16色模式下使用。
256色以下(包括256色)的DIB拥有自己的颜色表,像素的颜色独立于系统调色板。
由于DIB不依赖于具体设备,因此可以用来永久性地保存图象。
DIB一般是以*.BMP文件的形式保存在磁盘中的,有时也会保存在*.DIB文件中。
运行在不同输出设备下的应用程序可以通过DIB来交换图象。
/view/18734.htm怎么用VC把bmp图片的数据信息还原为图片并显示
用StretchDIBits函数。
假设你的数据存储在下面两个结构中:
BITMAPINFO bmi
PBYTE pbits
在视图类的OnDraw函数中添加一句:
::StretchDIBits(pDC->GetSafeHdc(),
0, 0, bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight,
0, 0, bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight,
pbits, bmi, DIB_RGB_COLORS, SRCCOPY );
即可
今天中午的时候有网友联系到在选择网站域名建站和主机的时候问到域名和IP地址有没有关联,或者需要注意的问题。毕竟我们在需要建站的时候,我们需要选择网站域名和主机,而主机有虚拟主机,包括共享和独立IP,同时还有云服务器、独立服务器、站群服务器等形式。通过这篇文章,简单的梳理关于网站域名和IP之间的关系。第一、什么是域名所谓网站域名,就是我们看到的类似"www.laozuo.org",我们可以通过直接记...
博鳌云是一家以海外互联网基础业务为主的高新技术企业,运营全球高品质数据中心业务。自2008年开始为用户提供服务,距今11年,在国人商家中来说非常老牌。致力于为中国用户提供域名注册(国外接口)、免费虚拟主机、香港虚拟主机、VPS云主机和香港、台湾、马来西亚等地服务器租用服务,各类网络应用解決方案等领域的专业网络数据服务。商家支持支付宝、微信、银行转账等付款方式。目前香港有一款特价独立服务器正在促销,...
一、麻花云官网点击直达麻花云官方网站二、活动方案优惠码:专属优惠码:F1B07B 享受85折优惠。点击访问活动链接最新活动 :五一狂欢 惠战到底 香港云主机 1.9折起香港特价体验云主机CN2 云服务器最新上线KVM架构,,默认40G SSD,+10G自带一个IPv4,免费10Gbps防御,CPU内存带宽价格购买1核1G1M19元首月链接2核2G 2M92元/3个月链接2核4G3M112元/3个月...
stretchdibits为你推荐
盗版win8.1升级win10盗版win10怎么升级到win10集成显卡和独立显卡哪个好独立显卡和集成显卡区别??闪迪和金士顿哪个好tf卡闪迪和金士顿哪个更好手机杀毒软件哪个好什么手机杀毒软件最好用?英语词典哪个好英语词典哪种更好啊?无纺布和熔喷布口罩哪个好医用 口罩里面是无纺布好还是过滤纸好手机管家哪个好手机管理软件哪个好用手机炒股软件哪个好手机炒股软件网校哪个好初中网校哪个好?海克斯皮肤哪个好lol100块抽11次的海克斯宝箱值得买吗
虚拟主机申请 欧洲免费vps 花生壳免费域名 免费申请域名 贝锐花生壳域名 ftp空间 美国独立服务器 pccw tier 香港主机 permitrootlogin 174.127.195.202 铁通流量查询 微信收钱 中国电信测网速 ftp免费空间 lick 贵阳电信测速 photobucket hdsky 更多