Пример #1
0
def rotate(im, angle):
    center = (im.width / 2.0, im.height / 2.0)
    mat = cv.CreateMat(2, 3, cv.CV_32FC1)
    cv.GetRotationMatrix2D(center, angle, 1.0, mat)
    out = cv.CreateImage(cv.GetSize(im), cv.IPL_DEPTH_8U, 1)
    cv.WarpAffine(im, out, mat, fillval=255)
    return out
    def img(self):
        '''return a cv image for the icon'''
        SlipThumbnail.img(self)

        if self.rotation:
            # rotate the image
            mat = cv.CreateMat(2, 3, cv.CV_32FC1)
            cv.GetRotationMatrix2D((self.width / 2, self.height / 2),
                                   -self.rotation, 1.0, mat)
            self._rotated = cv.CloneImage(self._img)
            cv.WarpAffine(self._img, self._rotated, mat)
        else:
            self._rotated = self._img
        return self._rotated
Пример #3
0
import cv2.cv as cv
import time

cv.NamedWindow("camera", 1)
capture = cv.CaptureFromCAM(0)

#set solution of camera
cv.SetCaptureProperty(capture, 3, 400)
cv.SetCaptureProperty(capture, 4, 300)

while True:
    img = cv.QueryFrame(capture)

    #smooth
    cv.Smooth(img, img, cv.CV_BLUR, 3)
    #hue_img = cv.CreateImage(cv.GetSize(img), 8 , 3)
    rows, cols = cv.GetSize(img)
    tmp_image = cv.fromarray(img)
    rotate_img = cv.GetRotationMatrix2D((cols / 2, rows / 2), 90, 1, tmp_image)
    #rotate_img = CV.warpAffine(,tmp_img, (cols,rows))
    #cv.CvtColor(img, hue_img, cv.CV_BGR2HSV)
    #threshold_img = cv.CreateImage(cv.GetSize(hue_img), 8 ,1)
    #cv.InRangeS(hue_img, (38,120,60), (75,255,255), threshold_img)

    cv.ShowImage("camera_origin", img)
    cv.ShowImage("Threshold", rotate_img)
    #as put ESC end the program
    if cv.WaitKey(10) == 27:
        break
cv.DestroyAllWindows()