เมื่อเกิดมาแล้ว พบสิ่งประเสริฐ ไม่ศึกษาเพื่อเข้าถึง น่าเสียดายมาก
Python - การทำ VideoCapture มาลง PyQt

ได้มาจากเวปอื่นตามนี้


from PyQt4 import QtGui
from PIL import Image

def get_pil_image(w, h):
    clr = chr(
0)+chr(255)+chr(0)
    im =
Image.fromstring("RGB", (w,h), clr*(w*h))
   
return im

def pil2qpixmap(pil_image):
    w, h = pil_image.size
    data = pil_image.tostring(
"raw", "BGRX")
    qimage =
QtGui.QImage(data, w, h, QtGui.QImage.Format_RGB32)
    qpixmap =
QtGui.QPixmap(w,h)
    pix =
QtGui.QPixmap.fromImage(qimage)
   
return pix

class ImageLabel(QtGui.QLabel):
   
def __init__(self, parent=None):
       
QtGui.QLabel.__init__(self, parent)

       
self.setGeometry(300, 300, 250, 150)
       
self.setWindowTitle('Window')

       
self.pix = pil2qpixmap(get_pil_image(50,50))
       
self.setPixmap(self.pix)

app =
QtGui.QApplication(sys.argv)
ImageLabel = ImageLabel()
ImageLabel.show()


ลองแล้วยังติดตรง QtGui.QImage.Format_RGB32


ถ้าใช้ได้ก็ตามนี้ครับ


sys.exit(app.exec_())


import VideoCapture


cam = VideoCapture.Device(devnum=0)


cam.setResolution(640, 480)


cam.saveSnapshot(filename = 'test.jpg', timestamp=3, boldfont=1, quality=75)


image = QPixmap("test.jpg")


self.label.setPixmap(image)





Create Date : 05 กรกฎาคม 2554
Last Update : 5 กรกฎาคม 2554 3:14:36 น. 1 comments
Counter : 742 Pageviews.

 


โดย: vootb วันที่: 5 กรกฎาคม 2554 เวลา:4:26:15 น.  

ชื่อ :
Comment :
  *ใช้ code html ตกแต่งข้อความได้เฉพาะสมาชิก
 

โอม37
Location :
Florida United States

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 1 คน [?]




มนุษย์คนหนึ่ง ชั่วดีมีปน หลง-วนตายเกิด พบรถด่วนขบวนสุดท้าย กำลังเข้าคิวตีตั๋ว
Group Blog
 
All Blogs
 
Friends' blogs
[Add โอม37's blog to your web]
Links
 

MY VIP Friend

 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.