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. |
|
|
แต่จะยืนยาวหรือไม่นั้นขึ้นอยู่กับ
"ความผูกพัน" ที่คนสองคนมีให้กัน
สวัสดีจ้า เข้ามาเยี่มชม มาทักทายกัน