Ask Your Question

vladan's profile - activity

2020-09-30 14:46:56 -0600 received badge  Notable Question (source)
2020-01-15 21:27:42 -0600 received badge  Popular Question (source)
2019-03-08 01:48:36 -0600 received badge  Famous Question (source)
2017-03-26 08:35:38 -0600 received badge  Notable Question (source)
2016-11-01 15:32:39 -0600 received badge  Popular Question (source)
2014-06-22 16:56:15 -0600 asked a question How to rotate whole canvas?

I want to show you output from ndimage rotation function and cv2 defined to make it easy to explain the problem. So I generate white rectangle on black canvas and rotate it with cv and then with scipy:

import cv2
import numpy as np
from scipy import ndimage

def rotate_image(im, angle):
    h, w = im.shape[:2]
    rot_mat = cv2.getRotationMatrix2D((w/2, h/2), angle, 1.0)
    return cv2.warpAffine(im, rot_mat, (w, h), flags=2)

img = np.zeros((300, 200))
img[10:290, 10:190] = 255

cv2.imwrite('img.png', img)
cv2.imwrite('cv2_rot.png', rotate_image(img, -30))
cv2.imwrite('scipy_rot.png', ndimage.rotate(img, -30))

These are the images generated:

  1. Test image:
  2. cv2 defined rotate function:
  3. ndimage rotate:

Hopfully it's obvious that I want to make cv2 rotate the image the way ndimage does - rotate the canvas without loosing original image content.

Does anyone know easy way to do that?

2014-03-29 09:26:37 -0600 asked a question How to set camera resolution?

I'm using Nokia N8 through USB as a PC camera. When I use camera capture utility I can set the resolution to one of:

 320 x 240
 640 x 480
 720 x 480
 720 x 576
1280 x 720

Screenshot from 1280x720:

<a href=http://i.imgur.com/mPpxCqCl.png">

But setting resolution to 1280x720 from opencv code:

cap = cv2.VideoCapture(0)

cap.set(3, 1280.)
cap.set(4, 720.)

yields no change, and camera is on some default 640x480 value:

<a href=http://i.imgur.com/gD6XWDHl.png">

Is there any other way to set the resolution?

2014-03-25 13:58:16 -0600 commented question VideoCapture.open() method does not seem to exist

done. a bit differently with requests: stream = requests.get(url, stream=True); stream.raw.read(); .... for anyone in similar trouble follow additionally http://stackoverflow.com/questions/21702477/how-to-parse-mjpeg-http-stream-from-ip-camera

2014-03-25 13:37:47 -0600 commented question VideoCapture.open() method does not seem to exist

ah yes, thanks. now i only need to find the name of the mjpeg stream...

2014-03-25 13:23:21 -0600 received badge  Editor (source)
2014-03-25 13:22:24 -0600 asked a question VideoCapture.open() method does not seem to exist

Hi,

I'm trying to capture video stream from ip cam. Googling around I wanted to try something like:

cv2.VideoCapture.open('http://address:port/videostream.cgi?user=user&password=ID:pass&channel=0&.mjpg')

but, cv2.VideoCapture.open() doesn't seem valid as I get exception, while I see in the docs that it should work:

Python: cv2.VideoCapture.open(filename) → retval
Python: cv2.VideoCapture.open(device) → retval

OTOH, trying:

cv2.VideoCapture('http://address:port/videostream.cgi?user=user&password=ID:pass&channel=0&.mjpg')

returs None

Using cv2 '2.4.8' with 64bit Python 2.7 on Windows 8 64bit