我想用openCV对16位RAW静态图像进行去拜耳处理,但是cvtColor函数有问题。颜色变成灰色可以给出正确的结果:
import cv2
import numpy as np
infile = '/media/rainer/IMG_2806.JPG'
img = cv2.imread(infile,1)
bw = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
resized = cv2.resize(bw, (0,0), fx=0.3, fy=0.3)
cv2.imshow('image',resized)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
那么debayer在python 2.7中会是什么样子?这不起作用:
infile = '/media/rainer/test.raw'
img = cv2.imread(infile,0)
debayer = cv2.cvtColor(img, cv2.CV_BayerBG2BGR)
resized = cv2.resize(debayer, (0,0), fx=0.3, fy=0.3)
cv2.imshow('image',resized)
cv2.waitKey(0)
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)
THX有很多帮助...。
我有一个pyqt gui并调用一个长进程(ffmpeg),我把它放在一个单独的线程上,以阻止gui.然后,我想在更长命令列表的一个命令完成时更新进度条.问题是,我无法在工作线程中调用gui线程中的函数.所以我在工作线程中运行一个自动收报机,但是当我用while循环更新进度条并读取自动收报机价值时,gui再次被阻止.我该怎么解决这个问题.我目前使用python线程而不是Qthread.感谢任何帮助!
import threading, pexpect
self.cmd_list = ['ffmpeg -i file outfile','and so on']
self.stop_proc = False
self.executeCMD()
def spawn_ffmpeg_cmd(self):
for cmd in self.cmd_list:
if self.stop_proc == False:
thread = pexpect.spawn(cmd)
print "\nstarted: %s" % cmd
cpl = thread.compile_pattern_list([pexpect.EOF,"frame= *\d+ fps=*\d+",'(.+)'])
while True:
i = thread.expect_list(cpl, timeout=None)
if i == 0: # EOF
print "the sub process exited"
self.pgticker += 1
break
elif i == 1:
frame_number_fps = thread.match.group(0)
print frame_number_fps
thread.close
elif i == 2:
pass
self.startButton.setEnabled(True)
def executeCMD(self):
self.startButton.setEnabled(False) …Run Code Online (Sandbox Code Playgroud)