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 );
即可
目前在标准互联这边有两台香港云服务器产品,这不看到有通知到期提醒才关注到。平时我还是很少去登录这个服务商的,这个服务商最近一年的促销信息比较少,这个和他们的运营策略有关系。已经从开始的倾向低价和个人用户云服务器市场,开始转型到中高端个人和企业用户的独立服务器。在这篇文章中,有看到标准互联有推出襄阳电信高防服务器100GB防御。有三款促销方案我们有需要可以看看。我们看看几款方案配置。型号内存硬盘IP...
丽萨主机怎么样?丽萨主机,团队于2017年成立。成立之初主要做的是 CDN 和域名等相关业务。最近开辟新领域,新增了独立服务器出租、VPS 等业务,为了保证业务质量从一开始就选择了中美之间的 CN2 GIA 国际精品网络,三网回程 CN2 GIA,电信去程 CN2 GIA + BGP 直连智能路由,联通移动去程直连,原生IP。适合对网络要求较高的用户,同时价格也比较亲民。点击进入:丽萨主机官方网站...
LayerStack(成立于2017年),当前正在9折促销旗下的云服务器,LayerStack的云服务器采用第 3 代 AMD EPYC™ (霄龙) 处理器,DDR4内存和企业级 PCIe Gen 4 NVMe SSD。数据中心可选中国香港、日本、新加坡和洛杉矶!其中中国香港、日本和新加坡分为国际线路和CN2线路,如果选择CN2线路,价格每月要+3.2美元,付款支持paypal,支付宝,信用卡等!...
stretchdibits为你推荐
软银收购arm英国的ARM 芯片公司宣布同中国芯片全面合作吗?腾讯空间首页腾讯空间主页哪去了天玑1000plus和骁龙865哪个好麒麟985处理器和天玑1000处理器哪个更好?涡轮增压和自然吸气哪个好发动机涡轮增压好还是自然吸气好51空间登录怎样登51个人空间yy空间登录怎么进入YY音乐空间360云存储360网盘目前最大空间是多少360云盘36t请问360云盘容量为什么最低有36T,其他IT行业的云盘都最多就2T?月抛隐形眼镜哪个牌子的月抛隐形眼镜比较好?便宜的反义词便宜的近义词是什么
域名邮箱 东莞电信局 hkbn raksmart kddi wdcp 国内php空间 彩虹ip 免费网站申请 bgp双线 idc资讯 ntfs格式分区 tna官网 网络空间租赁 卡巴斯基破解版 银盘服务是什么 域名与空间 国内域名 如何登陆阿里云邮箱 北京主机托管 更多