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 );
即可
无忧云怎么样?无忧云,无忧云是一家成立于2017年的老牌商家旗下的服务器销售品牌,现由深圳市云上无忧网络科技有限公司运营,是正规持证IDC/ISP/IRCS商家,主要销售国内、中国香港、国外服务器产品,线路有腾讯云国外线路、自营香港CN2线路等,都是中国大陆直连线路,非常适合免备案建站业务需求和各种负载较高的项目,同时国内服务器也有多个BGP以及高防节点。一、无忧云官网点击此处进入无忧云官方网站二...
野草云月末准备了一些促销,主推独立服务器,也有部分云服务器,价格比较有性价比,佣金是10%循环,如果有时间请帮我们推推,感谢!公司名:LucidaCloud Limited官方网站:https://www.yecaoyun.com/香港独立服务器:CPU型号内存硬盘带宽价格购买地址E3-1230v216G240GB SSD或1TB 企盘30M299元/月点击购买E5-265016G240GB SS...
俄罗斯vps速度怎么样?俄罗斯vps云主机节点是欧洲十大节点之一,地处俄罗斯首都莫斯科,网络带宽辐射周边欧洲大陆,10G专线连通德国法兰克福、法国巴黎、意大利米兰等,向外连接全球。俄罗斯vps云主机速度快吗、延迟多少?由于俄罗斯数据中心出口带宽充足,俄罗斯vps云主机到全球各地的延迟、速度相对来说都不错。今天,云服务器网(yuntue.com)小编介绍一下俄罗斯vps速度及俄罗斯vps主机推荐!俄...
stretchdibits为你推荐
杀毒软件哪个好杀毒软件什么最好燃气热水器和电热水器哪个好燃气热水器与电热水器的优缺点?骁龙765g和骁龙865哪个好骁龙865八核2.84H和骁龙855plus八核2.96GHZ那个好了?手动挡和自动挡哪个好手动档与自动档哪个好?三国游戏哪个好玩哪款三国游戏最好玩`!英语词典哪个好什么英语词典好?手机管家哪个好手机管家哪个软件好播放器哪个好安卓手机视频播放器哪个好点qq空间登录登陆进入QQ空间进去了叫登陆登陆了又叫登陆飞信空间登录飞信客户端空间登录 飞信绿色版历史记录
主机域名 qq域名邮箱 郑州服务器租用 英文简历模板word 光棍节日志 777te 最好的免费空间 135邮箱 爱奇艺vip免费试用7天 美国免费空间 东莞服务器 申请免费空间和域名 彩虹云 百度云空间 畅行云 测速电信 腾讯网盘 97rb 广东服务器托管 hdsky 更多