Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ROI region opencv c++ vs python

 Mat roi(img    , Rect(corners[0].x,corners[0].y,s,s));
    if(roi.rows<1||roi.cols<1)
    return empty;

I need to find ROI using above code

This is what I'm trying to do in python

x,y,w,h= [corners[0][0], corners[0][1],s,s]

(the values of x,y,w,h) is ((1161.4393398282202, -1.0606601717798214, 2.121320343559643, 2.121320343559643)

roi = image[y:y+h, x:x+w]

but getting error "TypeError: slice indices must be integers or None or have an __index__ method" Then I convert the value of x,y,w,h into int but doesn't work

I also tried to use cv2.selectROI(winsize,image) I inputted winsize i.e roi_win_size = x,y,w,h but still dosent work getting error "TypeError: only size-1 arrays can be converted to Python scalars"

please tell me what should I do.

ROI region opencv c++ vs python

 

Mat roi(img , Rect(corners[0].x,corners[0].y,s,s)); , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols<1) return empty;

empty;

I need to find ROI using above code

This is what I'm trying to do in python

 x,y,w,h= [corners[0][0], corners[0][1],s,s]
   roi = image[y:y+h, x:x+w]

(the values of x,y,w,h) is ((1161.4393398282202, -1.0606601717798214, 2.121320343559643, 2.121320343559643)

2.121320343559643)
roi = image[y:y+h, x:x+w]

but getting error "TypeError: slice indices must be integers or None or have an __index__ method" Then I convert the value of x,y,w,h into int but doesn't work

I also tried to use cv2.selectROI(winsize,image) I inputted winsize i.e roi_win_size = x,y,w,h but still dosent work getting error "TypeError: only size-1 arrays can be converted to Python scalars"

please tell me what should I do.

ROI region opencv c++ vs python

Mat roi(img , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols<1) return empty;

I need to find ROI using above code

This is what I'm trying to do in python

 x,y,w,h= [corners[0][0], corners[0][1],s,s]
   roi = image[y:y+h, x:x+w]

(the values of x,y,w,h) is ((1161.4393398282202, -1.0606601717798214, 2.121320343559643, 2.121320343559643) but getting error "TypeError: slice indices must be integers or None or have an __index__ method" Then I convert the value of x,y,w,h into int but doesn't work

I also tried to use cv2.selectROI(winsize,image) cv2.selectROI(winsize,image) winsize = x,y,w,h but still dosent work getting error "TypeError: only size-1 arrays can be converted to Python scalars"

please tell me what should I do.

ROI region opencv c++ vs python

Mat roi(img , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols<1) return empty;

I need to find ROI using above code

This is what I'm trying to do in python

 x,y,w,h= [corners[0][0], corners[0][1],s,s]
   roi = image[y:y+h, x:x+w]

(the values of x,y,w,h) is ((1161.4393398282202, -1.0606601717798214, 2.121320343559643, 2.121320343559643) but getting error "TypeError: slice indices must be integers or None or have an __index__ method" Then I convert the value of x,y,w,h into int but doesn't work

I also tried to use cv2.selectROI(winsize,image) winsize = x,y,w,h but still dosent work getting error "TypeError: only size-1 arrays can be converted to Python scalars"

please tell me what should I do.

ROI region opencv c++ vs python

Mat roi(img , roi(img, Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols<1) return empty;

I need to find ROI using above code

This is what I'm trying to do in python

 x,y,w,h= [corners[0][0], corners[0][1],s,s]
   roi = image[y:y+h, x:x+w]

(the values of x,y,w,h) is ((1161.4393398282202, -1.0606601717798214, 2.121320343559643, 2.121320343559643) but getting error "TypeError: slice indices must be integers or None or have an __index__ method" Then I convert the value of x,y,w,h into int but doesn't work

I also tried to use cv2.selectROI(winsize,image) winsize = x,y,w,h but still dosent work getting error "TypeError: only size-1 arrays can be converted to Python scalars"

please tell me what should I do.

ROI region opencv c++ vs python

Mat roi(img, roi(img , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols<1) return empty; Mat roi1(img, Rect(corners[1].x,corners[1].y,s,s)); if(roi1.rows<1||roi1.cols<1) return empty; Mat roi2(img, Rect(corners[2].x,corners[2].y,s,s)); if(roi2.rows<1||roi2.cols<1) return empty;

I need to find ROI using above code

This is what I'm trying to do in python

 x,y,w,h= [corners[0][0], corners[0][1],s,s]
   roi = image[y:y+h, x:x+w]

(the values of x,y,w,h) is ((1161.4393398282202, -1.0606601717798214, 2.121320343559643, 2.121320343559643) but getting error "TypeError: slice indices must be integers or None or have an __index__ method" Then I convert the value of x,y,w,h into int but doesn't work

I also tried to use cv2.selectROI(winsize,image) winsize = x,y,w,h but still dosent work getting error "TypeError: only size-1 arrays can be converted to Python scalars"

please tell me what should I do.

ROI region opencv c++ vs python

Define ROI:

Mat roi(img , Rect(corners[0].x,corners[0].y,s,s));
        roi(image,Rect(corners[0].x,corners[0].y,s,s));
if(roi.rows<1||roi.cols<1)
        return empty;
        Mat roi1(img, Rect(corners[1].x,corners[1].y,s,s));
        if(roi1.rows<1||roi1.cols<1)
        return empty;
        Mat roi2(img, Rect(corners[2].x,corners[2].y,s,s));
        if(roi2.rows<1||roi2.cols<1)
        return empty;

I need to find ROI using above code

This is what I'm trying to do in python

 x,y,w,h= [corners[0][0], corners[0][1],s,s]
   roi = image[y:y+h, x:x+w]

(the values of x,y,w,h) is ((1161.4393398282202, -1.0606601717798214, 2.121320343559643, 2.121320343559643) but getting error "TypeError: slice indices must be integers or None or have an __index__ method" Then I convert the value of x,y,w,h into int but doesn't work

I also tried to use cv2.selectROI(winsize,image) winsize = x,y,w,h but still dosent work getting error "TypeError: only size-1 arrays can be converted to Python scalars"

please tell me what should I do.