Ask Your Question

La Rosa's profile - activity

2019-05-26 15:41:40 -0600 received badge  Famous Question (source)
2017-10-11 11:35:53 -0600 received badge  Popular Question (source)
2017-06-02 19:25:06 -0600 received badge  Notable Question (source)
2017-01-10 00:38:22 -0600 received badge  Famous Question (source)
2016-10-31 20:47:45 -0600 received badge  Popular Question (source)
2015-12-14 18:06:41 -0600 received badge  Notable Question (source)
2015-06-23 12:08:32 -0600 received badge  Popular Question (source)
2014-05-14 11:00:02 -0600 asked a question use cvblob and opencv with python

Hello everybody i need to know how can i use the cvblob with opencv and python means how to install configure and test it thanks in advance

2014-05-03 09:31:01 -0600 asked a question cv2.line python error

I'm trying to draw line between 2 points but when i run the code i get this error:

SystemError: new style getargs format but argument is not a tuple

any help i'll be thankful

here is the part of code:

cv2.line(img, approx[0], approx[1],( 0, 0, 255),3)
2014-04-25 07:46:06 -0600 received badge  Editor (source)
2014-04-25 07:29:44 -0600 asked a question 3d reconstruction python and opencv

hi guys i have been working on a small program in python using the opencv lib and tow webcams so that i can measure the distance between this last tow and the object right in front of them(using the disparity map) ,so when i run the program at the end i normally i get the result in a matrix but what i get is not only one number(which is supposed to be the distance) but many different numbers,besides i always get one number which doesn't change even if i change the view can any body tell me why?!

here is the code:

import numpy as np
import cv2 as cv
import cv2.cv as cv1
from VideoCapture import Device
import os


def caliLeftCam():    
args, img_mask = getopt.getopt(sys.argv[1:], '', ['save=', 'debug=', 'square_size='])
args = dict(args)
try: img_mask = img_mask[0]
except: img_mask = '../cpp/img*.jpg'
img_names = glob(img_mask)
debug_dir = args.get('--debug')
square_size = float(args.get('--square_size', 1.0))

pattern_size = (7, 5)
pattern_points = np.zeros( (np.prod(pattern_size), 3), np.float32 )
pattern_points[:,:2] = np.indices(pattern_size).T.reshape(-1, 2)
pattern_points *= square_size

obj_points = []
img_pointsL = []
h, w = 0, 0
for fn in img_names:
    print "processing %s..." % fn,
    imgL = cv.imread(fn, 0)
    h, w = imgL.shape[:2]
    found, corners = cv.findChessboardCorners(imgL, pattern_size)
    if found:
        term = ( cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_COUNT, 30, 0.1 )
        cv.cornerSubPix(imgL, corners, (5, 5), (-1, -1), term)
    if debug_dir:
        vis = cv.cvtColor(imgL, cv.COLOR_GRAY2BGR)
        cv.drawChessboardCorners(vis, pattern_size, corners, found)
        path, name, ext = splitfn(fn)
        cv.imwrite('%s/%s_chess.bmp' % (debug_dir, name), vis)
    if not found:
        print "chessboard not found"
        continue
    img_pointsL.append(corners.reshape(-1, 2))
    obj_points.append(pattern_points)

    print 'ok'

rmsL, cameraL_matrix, dist_coefsL, rvecsL, tvecsL = cv.calibrateCamera(obj_points, img_pointsL, (w, h))
print "RMSL:", rmsL
print "Left camera matrix:\n", cameraL_matrix
print "distortion coefficients: ", dist_coefsL.ravel()

newcameramtxL, roi=cv.getOptimalNewCameraMatrix(cameraL_matrix,dist_coefsL,(w,h),1,(w,h))
#undistort
mapxL,mapyL = cv.initUndistortRectifyMap(cameraL_matrix,dist_coefsL,None,newcameramtxL,(w,h),5)
dstL = cv.remap(imgL,mapxL,mapyL,cv.INTER_LINEAR)
return img_pointsL, cameraL_matrix, dist_coefsL
def caliRightCam():

args, img_mask = getopt.getopt(sys.argv[1:], '', ['save=', 'debug=', 'square_size='])
args = dict(args)
try: img_mask = img_mask[0]
except: img_mask = '../cpp/ph*.jpg'
img_names = glob(img_mask)
debug_dir = args.get('--debug')
square_size = float(args.get('--square_size', 1.0))

pattern_size = (7, 5)
pattern_points = np.zeros( (np.prod(pattern_size), 3), np.float32 )
pattern_points[:,:2] = np.indices(pattern_size).T.reshape(-1, 2)
pattern_points *= square_size

obj_points = []
img_pointsR = []
h, w = 0, 0
for fn in img_names:
    print "processing %s..." % fn,
    imgR = cv.imread(fn, 0)
    h, w = imgR.shape[:2]
    found, corners = cv.findChessboardCorners(imgR, pattern_size)
    if found:
        term = ( cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_COUNT, 30, 0.1 )
        cv.cornerSubPix(imgR, corners, (5, 5), (-1, -1), term)
    if debug_dir:
        vis = cv.cvtColor(img, cv2.COLOR_GRAY2BGR)
        cv.drawChessboardCorners(vis, pattern_size, corners, found)
        path, name, ext = splitfn(fn)
        cv.imwrite('%s/%s_chess.bmp' % (debug_dir, name), vis)

    if not found:
        print "chessboard not found"
        continue
    img_pointsR.append(corners.reshape(-1, 2))
    obj_points.append(pattern_points)

    print 'ok'

rmsR, cameraR_matrix, dist_coefsR ...
(more)
2014-04-21 11:46:23 -0600 commented question cv2.imshow python

okay thank you

2014-04-21 11:35:29 -0600 commented question cv2.imshow python

thank you so much it works but could you tell me what is the difference ( i'm a little bit new in opencv)

2014-04-21 10:58:31 -0600 asked a question cv2.imshow python

can any body tell me whart is worng with this code cause when i run it i get no errors and yet no image is shown

from VideoCapture import Device

import cv2

import cv2.cv as cv

cam = Device(0)

cam.saveSnapshot('imageL.jpg')

fn = 'C:\Python276\imageL.jpg'

imageL = cv2.imread(fn,0)

cv2.imshow('Left',imageL)

if cv2.waitKey(1) & 0xFF == 27:

    cv.DestroyAllWindows()
2014-04-17 11:00:20 -0600 received badge  Scholar (source)
2014-04-16 12:01:52 -0600 asked a question import error:annot import name glog python

hi guys i'm getting the import error mentioned in the topic when i run this code:

import cv2 as cv

def caliLeftCam():
   import sys, getopt
   from glob import glog

   args, img_mask = getopt.getopt(sys.argv[1:], '', ['save=', 'debug=', 'square_size='])
   args = dict(args)
   try: img_mask = img_mask[0]
   except: img_mask = '../cpp/img*.jpg'
   img_names = glob(img_mask)
   debug_dir = args.get('--debug')
   square_size = float(args.get('--square_size', 1.0))

   pattern_size = (7, 5)
   pattern_points = np.zeros( (np.prod(pattern_size), 3), np.float32 )
   pattern_points[:,:2] = np.indices(pattern_size).T.reshape(-1, 2)
   pattern_points *= square_size

   obj_points = []
   img_pointsL = []
   h, w = 0, 0
for fn in img_names:
    print "processing %s..." % fn,
    imgL = cv.imread(fn, 0)
    h, w = imgL.shape[:2]
    found, corners = cv.findChessboardCorners(imgL, pattern_size)
    if found:
        term = ( cv.TERM_CRITERIA_EPS + cv.TERM_CRITERIA_COUNT, 30, 0.1 )
        cv.cornerSubPix(imgL, corners, (5, 5), (-1, -1), term)
    if debug_dir:
        vis = cv.cvtColor(imgL, cv.COLOR_GRAY2BGR)
        cv.drawChessboardCorners(vis, pattern_size, corners, found)
        path, name, ext = splitfn(fn)
        cv.imwrite('%s/%s_chess.bmp' % (debug_dir, name), vis)
    if not found:
        print "chessboard not found"
        continue
    img_pointsL.append(corners.reshape(-1, 2))
    obj_points.append(pattern_points)

    print 'ok'

    rmsL, cameraL_matrix, dist_coefsL, rvecsL, tvecsL = cv.calibrateCamera(obj_points, img_pointsL, (w, h))
    print "RMSL:", rmsL
    print "Left camera matrix:\n", cameraL_matrix
    print "distortion coefficients: ", dist_coefsL.ravel()

    newcameramtxL, roi=cv.getOptimalNewCameraMatrix(cameraL_matrix,dist_coefsL,(w,h),1,(w,h))
    #undistort
    mapxL,mapyL = cv.initUndistortRectifyMap(cameraL_matrix,dist_coefsL,None,newcameramtxL,(w,h),5)
    dstL = cv.remap(imgL,mapxL,mapyL,cv.INTER_LINEAR)
    return cameraL_matrix, dist_coefsL
if __name__ == '__main__':


  Cam_Mat, Dis = caliLeftCam()
  print 'matrix=' , Cam_Mat
  print 'distorcoef=' , Dis

any one can help me thank's in advance

2014-04-06 08:15:53 -0600 asked a question cv2.drawcontours python and opencv

hi guys i am using the cv2.drawcontours function to draw contours on webcam stream i want to know how can i add a track-bar to precis which contours to draw based on the hierarchy parameter of the cv2.findcontours function here is the code

import cv2

import cv2.cv as cv

cv2.namedWindow("test")

vc = cv2.VideoCapture(2);

retVal, frame = vc.read();

while True:

if frame is not None:   

    imgray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
    ret,thresh = cv2.threshold(imgray,127,255,0)
    contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
    cv2.drawContours(frame, contours, -1, (0,255,0), 2)


    cv2.imshow("test", frame)

rval, frame = vc.read()


if cv2.waitKey(1) & 0xFF == 27:
    break

cv.DestroyAllWindows()

2014-03-29 09:32:11 -0600 asked a question Object detection python

hi guys i want to use Opencv in order to detect objects in real-time using two webcams so that i'll be able to measure the distance between the cams and the objects. the problem is that i don't know from where should i start? and which algorithm is the best? any little help I'll be thankfull

2014-03-18 10:39:34 -0600 commented answer calculate distance using disparity map

yopiii :) , thank you sooooo much

2014-03-18 10:03:46 -0600 commented answer calculate distance using disparity map

it works but i'm getting the result in an matrix?!! is that ok?

2014-03-18 08:11:18 -0600 commented question calculate distance using disparity map

Any help please!

2014-03-17 13:19:15 -0600 asked a question calculate distance using disparity map

i am wondering how can i calculate the distance between tow webcams(stereo vision) and an object in front of them using the disparity map?

2014-03-17 13:10:52 -0600 commented question cv2.CreateMat in python

ok ;) thank you

2014-03-17 12:56:09 -0600 commented question cv2.CreateMat in python

it's okay ,I've used the wrong image :p now All is done how can i get the distance from the disparity map

2014-03-17 12:30:09 -0600 commented question cv2.CreateMat in python

i'm getting this error: colors = cv.cvtColor(imgL, cv.COLOR_BGR2RGB) error: ......\src\opencv\modules\imgproc\src\color.cpp:3346: error: (-215) scn == 3 || scn == 4 :/ ?!!

2014-03-17 11:16:39 -0600 commented question cv2.CreateMat in python

okay i really appreciate,now it works,thank you now moving to the next step thank you again

2014-03-17 11:05:50 -0600 commented question cv2.CreateMat in python

ok,but still getting this error: ValueError: too many values to unpack in this line RL, Rr, PL, PR, Q = cv.stereoRectify(camera_matrixL,dist_coefsL, cameraR_matrix, dist_coefsR,(384,288), R, T) (and i'm so sorry if i am bothering you)

2014-03-17 10:41:50 -0600 commented question cv2.CreateMat in python

and how about the R1,R2,P1,P2,Q?

2014-03-17 10:38:03 -0600 commented question cv2.CreateMat in python

i am using cv2 but just (import cv2 as cv)

2014-03-17 10:36:50 -0600 commented question cv2.CreateMat in python

yes it is!

2014-03-17 10:21:41 -0600 commented question cv2.CreateMat in python

hi again, i tried to run the cv2.stereoRectify but i got this error:

Traceback (most recent call last): File "C:\opencv246\samples\python2\stereocalib.py", line 132, in <module> cv.stereoRectify(camera_matrixL, cameraR_matrix, dist_coefsL, dist_coefsR,(384,288), R, T, RL, Rr, PL, PR) error: ......\src\opencv\modules\imgproc\src\undistort.cpp:292: error: (-215) CV_IS_MAT(_distCoeffs) && (_distCoeffs->rows == 1 || _distCoeffs->cols == 1) && (_distCoeffs->rows_distCoeffs->cols == 4 || _distCoeffs->rows_distCoeffs->cols == 5 || _distCoeffs->rows*_distCoeffs->cols == 8) why?!

2014-03-17 09:53:20 -0600 commented question cv2.CreateMat in python

okay working on it thank you

2014-03-17 09:41:42 -0600 commented question cv2.CreateMat in python

ok,i did it and it works now thank you one more question please what will the next step be in order to be able to calculate the distance between the tow webcams and the object in front of them?

2014-03-16 15:32:03 -0600 commented question cv2.CreateMat in python

okay thank you so much (please if you can help me in cv.stereoCalibration, how to calculate R,T,F,E?i'll be thankful) waiting for your explanation tomorrow.

2014-03-16 15:15:46 -0600 commented question cv2.CreateMat in python

Sorry but i didn't understand you (i'm new in opencv and python) how can i create matrix?!

2014-03-16 14:15:32 -0600 asked a question cv2.CreateMat in python

Hi guys

i'm trying to use the cv.CreateMat in a python code but when i run it i got this error:

AttributeError: 'module' object has no attribute 'createMat'!!!!!

Please can anybody help me! thank you