核心代码

import wx, cv2
import numpy as np # Start with a numpy array style image I'll call "source" # convert the colorspace to RGB from cv2 standard BGR, ensure input is uint8
img = cv2.cvtColor(np.uint8(source), cv2.cv.CV_BGR2RGB) # get the height and width of the source image for buffer construction
h, w = img.shape[:2] # make a wx style bitmap using the buffer converter
wxbmp = wx.BitmapFromBuffer(w, h, img) # Example of how to use this to set a static bitmap element called "bitmap_1"
self.bitmap_1.SetBitmap(wxbmp)

实例程序

import wx, cv2
import numpy as np class Frame(wx.Frame):
def __init__(self,parent=None,id=-1,pos=wx.DefaultPosition,title="Hello,wxPython!"):
source = cv2.imread('./6.jpg', cv2.IMREAD_COLOR)
img = cv2.cvtColor(np.uint8(source), cv2.cv.CV_BGR2RGB)
h, w = img.shape[:2]
wxbmp = wx.BitmapFromBuffer(w, h, img)
size = wxbmp.GetWidth(),wxbmp.GetHeight()
wx.Frame.__init__(self,parent,id,title,pos,size)
wx.StaticBitmap(parent=self,bitmap=wxbmp) class App(wx.App):
def OnInit(self):
self.frame = Frame()
self.frame.Show()
self.SetTopWindow(self.frame)
return True def main():
app = App()
app.MainLoop() if __name__ == "__main__":
main()

利用wxpython显示OpenCV图像的更多相关文章

  1. [OpenCV Qt教程] 在Qt图形界面中显示OpenCV图像的OpenGL Widget(第二部分)

    本文译自:http://www.robot-home.it/blog/en/software/tutorial-opencv-qt-opengl-widget-per-visualizzare-imm ...

  2. [OpenCV Qt教程] 在Qt图形界面中显示OpenCV图像的OpenGL Widget (第一部分)

    本文译自:http://www.robot-home.it/blog/en/software/tutorial-opencv-qt-opengl-widget-per-visualizzare-imm ...

  3. Imagelab-0-QT label显示 opencv 图像

    Imagelab-0-QT label显示 opencv 图像 opencvc++qtimagelab 开始之前 这其实也是opencv 处理图像的系列, 只是想我们在进一步复杂化我们的代码之前, 每 ...

  4. Kinect For Windows V2开发日志四:使用OpenCV显示深度图像

    代码示例: #include <Kinect.h> #include <iostream> #include <opencv2\highgui.hpp> using ...

  5. 一个显示 OpenCV Mat 图像的自定义 Qt 控件

    今天学习 Qt 的时候顺手写了一个,包含一个头文件 qcvdisplay.h 和一个源文件 qcvdisplay.cpp,因为这是 qt 默认的文件命名方式,在 Qt Designer 中提升控件时会 ...

  6. 使用GDI+显示OpenCV中的图像IplImage

    OpenCV虽然自带了轻量级的界面库HighGUI,但是支持的图像化元素实在是太少了,一般只在前期算法测试时使用.实际产品还是使用MFC库.因此本文记录了如何在GDI+中显示OpenCV中的IplIm ...

  7. OpenCV图像载入、显示和输出到文件以及滑块的使用

    图像载入 imread()函数 Mat imread(const string& filename, int flags = 1); 第一个参数为文件名 第二个参数为载入标识 flags &g ...

  8. OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放

    这篇已经写得很好,真心给作者点个赞.题目都是直接转过来的,直接去看吧. Reference Link : http://blog.csdn.net/poem_qianmo/article/detail ...

  9. 【OpenCV新手教程之十三】OpenCV图像金字塔:高斯金字塔、拉普拉斯金字塔与图片尺寸缩放

    本系列文章由@浅墨_毛星云 出品,转载请注明出处. 文章链接:http://blog.csdn.net/poem_qianmo/article/details/26157633 作者:毛星云(浅墨) ...

随机推荐

  1. 用Golang写的域名信息搜集工具

    blacksheepwall是一款由Go语言编写的域名信息搜集工具 ,你也可以在你的工具中将它作为一个独立软件包来使用. 下载 blacksheepwall支持跨平台,目前它所支持的系统有window ...

  2. python发送邮件(转)

    SMTP发送邮件 阅读: 90274 SMTP是发送邮件的协议,Python内置对SMTP的支持,可以发送纯文本邮件.HTML邮件以及带附件的邮件. Python对SMTP支持有smtplib和ema ...

  3. 实例化Spring容器的两种常用方式

    //在类路径下寻找配置文件来实例化容器 ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"b ...

  4. linux中read用法

    read在while中的经常用法: root@ubuntu:/var/lib/logrotate :: # cat /etc/cron.daily/logrotate #!/bin/sh # Clea ...

  5. 报错: Access restriction: The type JPEGImageEncoder is not accessible due to restriction on required library

    报错: Access restriction:The type JPEGCodec is not accessible due to restriction on required library C ...

  6. Android世界第一个activity启动过程

    Android世界第一个activity启动过程 第一次使用Markdown,感觉不错. Android系统从按下开机键一直到launcher的出现,是一个如何的过程,中间都做出了什么操作呢.带着这些 ...

  7. vue2.0 引用qrcode.js实现获取改变二维码的样式

    vue代码 <template> <div class="qart"> <div id="qrcode" ref="qr ...

  8. vscode 折叠所有区域

  9. Hive命令详解

    http://blog.itpub.net/22778222/viewspace-1119892/  官方文档翻译 http://blog.csdn.net/hguisu/article/detail ...

  10. 抽象类(abstract)和接口(interface)的区别

    1 抽象类是不能被实例化的类,只能作为由其他类继承的基类:    接口则定义了实现某种服务的一般规范(Objective-C中将接口称为“协议”(protocol)),声明了必需的函数和常量,但不指定 ...