当前位置: 首页>>代码示例>>Python>>正文


Python cv.ShowImage方法代码示例

本文整理汇总了Python中cv2.cv.ShowImage方法的典型用法代码示例。如果您正苦于以下问题:Python cv.ShowImage方法的具体用法?Python cv.ShowImage怎么用?Python cv.ShowImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cv2.cv的用法示例。


在下文中一共展示了cv.ShowImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def main():
    """Open test color images, create display window, start the search"""
    cv.NamedWindow(WNDNAME, 1)
    for name in [ "../c/pic%d.png" % i for i in [1, 2, 3, 4, 5, 6] ]:
        img0 = cv.LoadImage(name, 1)
        try:
            img0
        except ValueError:
            print "Couldn't load %s\n" % name
            continue

        # slider deleted from C version, same here and use fixed Canny param=50
        img = cv.CloneImage(img0)

        cv.ShowImage(WNDNAME, img)

        # force the image processing
        draw_squares( img, find_squares4( img ) )

        # wait for key.
        if cv.WaitKey(-1) % 0x100 == 27:
            break 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:24,代码来源:cv20squares.py

示例2: drawSquares

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def drawSquares(img, squares):
    cpy = cv.CloneImage(img)
    # read 4 sequence elements at a time (all vertices of a square)
    i=0
    while i<squares.total:
        pt = []
        # read 4 vertices
        pt.append(squares[i])
        pt.append(squares[i+1])
        pt.append(squares[i+2])
        pt.append(squares[i+3])

        # draw the square as a closed polyline
        cv.PolyLine(cpy, [pt], 1, cv.CV_RGB(0, 255, 0), 3, cv. CV_AA, 0)
        i+=4

    # show the resultant image
    cv.ShowImage(wndname, cpy) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:20,代码来源:squares.py

示例3: on_trackbar

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def on_trackbar(position):

    cv.Smooth(gray, edge, cv.CV_BLUR, 3, 3, 0)
    cv.Not(gray, edge)

    # run the edge dector on gray scale
    cv.Canny(gray, edge, position, position * 3, 3)

    # reset
    cv.SetZero(col_edge)

    # copy edge points
    cv.Copy(im, col_edge, edge)

    # show the im
    cv.ShowImage(win_name, col_edge) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:18,代码来源:edge.py

示例4: on_trackbar

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def on_trackbar(edge_thresh):

    cv.Threshold(gray, edge, float(edge_thresh), float(edge_thresh), cv.CV_THRESH_BINARY)
    #Distance transform
    cv.DistTransform(edge, dist, cv.CV_DIST_L2, cv.CV_DIST_MASK_5)

    cv.ConvertScale(dist, dist, 5000.0, 0)
    cv.Pow(dist, dist, 0.5)

    cv.ConvertScale(dist, dist32s, 1.0, 0.5)
    cv.AndS(dist32s, cv.ScalarAll(255), dist32s, None)
    cv.ConvertScale(dist32s, dist8u1, 1, 0)
    cv.ConvertScale(dist32s, dist32s, -1, 0)
    cv.AddS(dist32s, cv.ScalarAll(255), dist32s, None)
    cv.ConvertScale(dist32s, dist8u2, 1, 0)
    cv.Merge(dist8u1, dist8u2, dist8u2, None, dist8u)
    cv.ShowImage(wndname, dist8u) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:19,代码来源:distrans.py

示例5: image_captured

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def image_captured(self, args):
		(img, rect) = args
		(x, y, w, h) = rect

		cv2.rectangle(numpy.asarray(img[:,:]), (x,y+1), (x+w,y+1+h), (0, 0, 0))
		cv2.rectangle(numpy.asarray(img[:,:]), (x,y), (x+w,y+h), (50, 50, 250))
		
		#cv.PutText(img, message, (0,y+1+2*h), font, (255, 255, 255))
		#cv.PutText(img, message, (0,y+2*h), font, (0, 0, 0))
		#cv.ShowImage('Capture Feedback', cv2.fromarray(img[:,:]))
		cv.ShowImage('Capture Feedback', img) 
开发者ID:starstuffharvestingstarlight,项目名称:tcg-ocr-scanner,代码行数:13,代码来源:handlers.py

示例6: run

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def run(self):
        started = time.time()
        while True:
            
            currentframe = cv.QueryFrame(self.capture)
            instant = time.time() #Get timestamp o the frame
            
            self.processImage(currentframe) #Process the image
            
            if not self.isRecording:
                if self.somethingHasMoved():
                    self.trigger_time = instant #Update the trigger_time
                    if instant > started +10:#Wait 5 second after the webcam start for luminosity adjusting etc..
                        print "Something is moving !"
                        if self.doRecord: #set isRecording=True only if we record a video
                            self.isRecording = True
                cv.DrawContours (currentframe, self.currentcontours, (0, 0, 255), (0, 255, 0), 1, 2, cv.CV_FILLED)
            else:
                if instant >= self.trigger_time +10: #Record during 10 seconds
                    print "Stop recording"
                    self.isRecording = False
                else:
                    cv.PutText(currentframe,datetime.now().strftime("%b %d, %H:%M:%S"), (25,30),self.font, 0) #Put date on the frame
                    cv.WriteFrame(self.writer, currentframe) #Write the frame
            
            if self.show:
                cv.ShowImage("Image", currentframe)
                
            c=cv.WaitKey(1) % 0x100
            if c==27 or c == 10: #Break if user enters 'Esc'.
                break 
开发者ID:alduxvm,项目名称:rpi-opencv,代码行数:33,代码来源:motion-detection.py

示例7: __init__

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def __init__(self, img0):
        self.thresh1 = 255
        self.thresh2 = 30
        self.level =4
        self.storage = cv.CreateMemStorage()
        cv.NamedWindow("Source", 0)
        cv.ShowImage("Source", img0)
        cv.NamedWindow("Segmentation", 0)
        cv.CreateTrackbar("Thresh1", "Segmentation", self.thresh1, 255, self.set_thresh1)
        cv.CreateTrackbar("Thresh2", "Segmentation",  self.thresh2, 255, self.set_thresh2)
        self.image0 = cv.CloneImage(img0)
        self.image1 = cv.CloneImage(img0)
        cv.ShowImage("Segmentation", self.image1) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:15,代码来源:pyramid_segmentation.py

示例8: on_segment

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def on_segment(self):
        comp = cv.PyrSegmentation(self.image0, self.image1, self.storage, \
                            self.level, self.thresh1+1, self.thresh2+1)
        cv.ShowImage("Segmentation", self.image1) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:6,代码来源:pyramid_segmentation.py

示例9: detect_and_draw

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def detect_and_draw(img, cascade):
    # allocate temporary images
    gray = cv.CreateImage((img.width,img.height), 8, 1)
    small_img = cv.CreateImage((cv.Round(img.width / image_scale),
                   cv.Round (img.height / image_scale)), 8, 1)

    # convert color input image to grayscale
    cv.CvtColor(img, gray, cv.CV_BGR2GRAY)

    # scale input image for faster processing
    cv.Resize(gray, small_img, cv.CV_INTER_LINEAR)

    cv.EqualizeHist(small_img, small_img)

    if(cascade):
        t = cv.GetTickCount()
        faces = cv.HaarDetectObjects(small_img, cascade, cv.CreateMemStorage(0),
                                     haar_scale, min_neighbors, haar_flags, min_size)
        t = cv.GetTickCount() - t
        print "detection time = %gms" % (t/(cv.GetTickFrequency()*1000.))
        if faces:
            for ((x, y, w, h), n) in faces:
                # the input to cv.HaarDetectObjects was resized, so scale the
                # bounding box of each face and convert it to two CvPoints
                pt1 = (int(x * image_scale), int(y * image_scale))
                pt2 = (int((x + w) * image_scale), int((y + h) * image_scale))
                cv.Rectangle(img, pt1, pt2, cv.RGB(255, 0, 0), 3, 8, 0)

    cv.ShowImage("result", img) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:31,代码来源:facedetect.py

示例10: on_mouse

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def on_mouse(self, event, x, y, flags, param):
        pt = (x, y)
        if event == cv.CV_EVENT_LBUTTONUP or not (flags & cv.CV_EVENT_FLAG_LBUTTON):
            self.prev_pt = None
        elif event == cv.CV_EVENT_LBUTTONDOWN:
            self.prev_pt = pt
        elif event == cv.CV_EVENT_MOUSEMOVE and (flags & cv.CV_EVENT_FLAG_LBUTTON) :
            if self.prev_pt:
                for dst in self.dests:
                    cv.Line(dst, self.prev_pt, pt, cv.ScalarAll(255), 5, 8, 0)
            self.prev_pt = pt
            cv.ShowImage(self.windowname, img) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:14,代码来源:watershed.py

示例11: draw_squares

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def draw_squares( color_img, squares ):
    """
    Squares is py list containing 4-pt numpy arrays. Step through the list
    and draw a polygon for each 4-group
    """
    color, othercolor = RED, GREEN
    for square in squares:
        cv.PolyLine(color_img, [square], True, color, 3, cv.CV_AA, 0)
        color, othercolor = othercolor, color

    cv.ShowImage(WNDNAME, color_img) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:13,代码来源:cv20squares.py

示例12: Closing

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def Closing(pos):
    element = cv.CreateStructuringElementEx(pos*2+1, pos*2+1, pos, pos, element_shape)
    cv.Dilate(src, image, element, 1)
    cv.Erode(image, dest, element, 1)
    cv.ShowImage("Opening & Closing", dest) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:7,代码来源:morphology.py

示例13: Erosion

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def Erosion(pos):
    element = cv.CreateStructuringElementEx(pos*2+1, pos*2+1, pos, pos, element_shape)
    cv.Erode(src, dest, element, 1)
    cv.ShowImage("Erosion & Dilation", dest) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:6,代码来源:morphology.py

示例14: Dilation

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def Dilation(pos):
    element = cv.CreateStructuringElementEx(pos*2+1, pos*2+1, pos, pos, element_shape)
    cv.Dilate(src, dest, element, 1)
    cv.ShowImage("Erosion & Dilation", dest) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:6,代码来源:morphology.py

示例15: update_brightcont

# 需要导入模块: from cv2 import cv [as 别名]
# 或者: from cv2.cv import ShowImage [as 别名]
def update_brightcont(self):
        # The algorithm is by Werner D. Streidt
        # (http://visca.com/ffactory/archives/5-99/msg00021.html)

        if self.contrast > 0:
            delta = 127. * self.contrast / 100
            a = 255. / (255. - delta * 2)
            b = a * (self.brightness - delta)
        else:
            delta = -128. * self.contrast / 100
            a = (256. - delta * 2) / 255.
            b = a * self.brightness + delta

        cv.ConvertScale(self.src_image, self.dst_image, a, b)
        cv.ShowImage("image", self.dst_image)

        cv.CalcArrHist([self.dst_image], self.hist)
        (min_value, max_value, _, _) = cv.GetMinMaxHistValue(self.hist)
        cv.Scale(self.hist.bins, self.hist.bins, float(self.hist_image.height) / max_value, 0)

        cv.Set(self.hist_image, cv.ScalarAll(255))
        bin_w = round(float(self.hist_image.width) / hist_size)

        for i in range(hist_size):
            cv.Rectangle(self.hist_image, (int(i * bin_w), self.hist_image.height),
                         (int((i + 1) * bin_w), self.hist_image.height - cv.Round(self.hist.bins[i])),
                         cv.ScalarAll(0), -1, 8, 0)

        cv.ShowImage("histogram", self.hist_image) 
开发者ID:fatcloud,项目名称:PyCV-time,代码行数:31,代码来源:demhist.py


注:本文中的cv2.cv.ShowImage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。