Ask Your Question

Rohan12111's profile - activity

2018-10-29 03:40:39 -0600 received badge  Popular Question (source)
2018-05-15 17:56:23 -0600 received badge  Famous Question (source)
2016-10-23 03:39:33 -0600 received badge  Notable Question (source)
2016-03-28 03:44:14 -0600 received badge  Popular Question (source)
2013-06-07 04:36:20 -0600 received badge  Student (source)
2013-06-05 07:33:21 -0600 asked a question Python crop not working

Hello, I am relatively new to OpenCV. I have gleaned from tutorials and such that you can crop by using this script:

import cv2
import numpy as np
import video

cam = cv2.VideoCapture(0)
ret,vis = cam.read()    
crop = vis[100:400, 100:300]    
cv2.imshow("Img",vis)
cv2.imshow("Crop",crop)    
cv2.waitKey(0)

And this works fine. I get no errors.

However, when i put it into my main script, it doesn't work, i've narrowed it down to this section of code:

def PicTake(self):
    ret,vis = self.cam.read()
    x1,y1 = self.selection[0]
    x2,y2 = self.selection[1]
    a = 0
    taken = 0
    while taken == 0:
        if cv2.imread("C:\Python27\opencv\samples\python2\Major\Test"+str(a)+".png") == None:
            crop = vis[x1:y1, x2:y2]
            print crop
            cv2.imshow("crop",crop)
            cv2.imwrite("C:\Python27\opencv\samples\python2\Major\Test"+str(a)+".png",crop)
            taken = 1
        else:
            a+=1
    return ("Picture Taken")

where self.selection is just a list of two tuples [(x1,y1),(x2,y2)]. After the first if statement, print crop returns "[]" and empty list.

So yeah, why does it work with numbers and other situations fine, but not here?!

Any help is greatly appreciated, thanks!

2013-06-03 06:23:51 -0600 asked a question How do i convert a video feed numpy array to an img array

Hi there,

I'm using cv2 and python.

I'm trying to change my program from checking two images against each other to checking a video feed against a video. So when i get the cam.read(), how do i change it to the same type of array you get when you cv2.imread() an img.

Thanks, any help is appreciated :)

2013-05-29 05:41:24 -0600 commented answer How do I install the old cv not cv2?! Python

So you don't know how to call it?

2013-05-29 04:59:30 -0600 commented answer How do I install the old cv not cv2?! Python

So how would i use cv2 to import cv into the program? Thank you very much :)

2013-05-28 01:00:24 -0600 received badge  Editor (source)
2013-05-28 00:58:55 -0600 asked a question How do I install the old cv not cv2?! Python

Hi there, I'm having trouble looking for a way to install the old cv. If anyone has any ideas how to do it, that would be great! Thanks

2013-05-15 19:03:43 -0600 asked a question python, pygame and opencv mixing?

Hi there, I'm using cv2 for a school major work. And I was wondering, is there a way to get a cv window into a pygame window. And if not, is there a way to either integrate a cv window into tkinter OR include a GUI interface using cv2 functions.

Thanks for you time.