Ask Your Question

Sky31's profile - activity

2019-07-19 04:54:41 -0600 edited question Color consistency algorithms python

Color consistency algorithms python Hey folks, I'm working on forgery detection (pixel and edge-based Color Estimation)

2019-07-19 04:53:55 -0600 asked a question Color consistency algorithms python

Color consistency algorithms python Hey folks, I'm working on forgery detection (pixel and edge-based Color Estimation)

2019-04-22 13:48:23 -0600 edited question Contour + hough Transformation

Contour + hough Transformation Hello folks, currently, I'm working on a project where I have to detect a card let say "

2019-04-22 13:47:43 -0600 edited question Contour + hough Transformation

Contour + hough Transformation Hello folks, currently, I'm working on a project where I have to detect a card let say "

2019-04-22 13:42:36 -0600 asked a question Contour + hough Transformation

Contour + hough Transformation Hello folks, currently, I'm working on a project where I have to detect a card let say "

2019-01-21 04:09:01 -0600 commented question How to Label the image dataset?

Correct me If I'm wrong. Steps to execute: Let's say I Input car dataset (1500 images) and create BOW dictionary, ext

2019-01-21 03:30:42 -0600 commented question How to Label the image dataset?

Features are the key-points which I extracted using SIFT/SURF. I just need to give labels to each individual dataset le

2019-01-21 02:34:46 -0600 commented question How to Label the image dataset?

yes, I'm working on the classification task. I need to classify the ID documents in the final project. currently, I'm ju

2019-01-19 09:26:30 -0600 commented answer How exactly does BoVW work for Python-3 Open cv3?

How you label the data?

2019-01-19 09:09:27 -0600 asked a question How to Label the image dataset?

How to Label the image dataset? Hello folks, I'm working on BOVW. I have some images lets say the car, bike etc. so my

2019-01-09 10:30:36 -0600 received badge  Supporter (source)
2019-01-09 10:30:33 -0600 marked best answer ROI region opencv c++ vs python

Define ROI:

Mat roi(image,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.

2019-01-02 05:09:29 -0600 received badge  Enthusiast
2019-01-01 18:08:13 -0600 marked best answer histogram opencv c++ vs python

I'm converting histogram function which is written in c++ into python.

    Mat  Detection:: histogram(Mat img,bool vis)
{
    int bins = 59;             // number of bins 256 -1 to ignore the last patterns (background pattern)

    Mat hist;       // histogram arrays
    // Initalize histogram array
    hist = Mat::zeros(bins, 1, CV_32FC1);
    for (int i = 0; i < img.rows; i++)
    {
        for (int j = 0; j < img.cols; j++)
        {
                uchar val =img.at<uchar>(i,j);
                hist.at<float>(lookup[val]) += 1;   #on this line I'm facing the problem(is it talking about the lookup table? )
        }
    }

    return hist;
}

python conversion

def historgram(image):
    #cv2.historgram()
    bins = 59
    row,col,channels = image.shape

    hist = np.zeros((bins, 1), dtype = 'float32')    
    i = 0 
    j =0 
    while i < row:
        while j < col:
            val = image[i,j]
           ""
                      ""

            j = j+1
        i = 1+i
    return hist

How should I do the conversion in python of this part [hist.at<float>(lookup[val]) += 1]?

Thankyou

2019-01-01 18:07:17 -0600 edited question ROI region opencv c++ vs python

ROI region opencv c++ vs python Define ROI: Mat roi(image,Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.c

2019-01-01 18:05:33 -0600 edited question ROI region opencv c++ vs python

ROI region opencv c++ vs python Mat roi(img , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols&l

2019-01-01 18:04:43 -0600 edited question ROI region opencv c++ vs python

ROI region opencv c++ vs python Mat roi(img, Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi

2019-01-01 18:04:17 -0600 edited question ROI region opencv c++ vs python

ROI region opencv c++ vs python Mat roi(img , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.co

2019-01-01 17:24:30 -0600 edited question ROI region opencv c++ vs python

ROI region opencv c++ vs python Mat roi(img , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols&l

2019-01-01 17:24:16 -0600 edited question ROI region opencv c++ vs python

ROI region opencv c++ vs python Mat roi(img , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols&l

2019-01-01 17:22:58 -0600 asked a question ROI region opencv c++ vs python

ROI region opencv c++ vs python Mat roi(img , Rect(corners[0].x,corners[0].y,s,s)); if(roi.rows<1||roi.cols&l

2019-01-01 04:58:16 -0600 commented answer histogram opencv c++ vs python

Thanks a lot :)

2019-01-01 03:39:38 -0600 edited question histogram opencv c++ vs python

histogram opencv c++ vs python I'm converting histogram function which is written in c++ into python. Mat Detectio

2019-01-01 03:31:22 -0600 edited question histogram opencv c++ vs python

histogram opencv c++ vs python I'm converting histogram function which is written in c++ into python. Mat Detectio

2019-01-01 03:30:51 -0600 edited question histogram opencv c++ vs python

histogram opencv c++ vs python I'm converting histogram function which is written in c++ into python. Mat Detectio

2019-01-01 03:29:44 -0600 commented question histogram opencv c++ vs python

I just updated the code Kindly look into it

2019-01-01 03:29:13 -0600 edited question histogram opencv c++ vs python

histogram opencv c++ vs python I'm converting histogram function which is written in c++ into python. Mat Detectio

2019-01-01 03:28:19 -0600 edited question histogram opencv c++ vs python

histogram opencv c++ vs python I'm converting histogram function which is written in c++ into python. Mat Detectio

2018-12-31 18:51:30 -0600 edited question histogram opencv c++ vs python

histogram opencv c++ vs python I'm converting histogram function which is written in c++ into python. uchar val =img.at

2018-12-31 18:38:07 -0600 asked a question histogram opencv c++ vs python

histogram opencv c++ vs python I'm converting histogram function which is written in c++ into python. uchar val =img.at

2018-12-31 13:43:21 -0600 marked best answer Translating C++ code into python. Facing some problem

Hello guys, I need your help.

I'm trying to translate c++ code into python but stuck somewhere.

Below is the code, which I have to convert.

oid Detection::findBestContour(Mat edge , vector<point> & contour ,vector<point> &hull,bool vis ) { vector<vector<point> > contours; vector<vec4i> hierarchy; int maxIndex=0,maxArea=0,tmpArea=0,minArea=100; // find the contours findContours( edge , contours, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE, Point(0, 0) ); //compute the convex hull vector<vector<point> >hulls( contours.size() ); for( int i = 0; i < contours.size(); i++ ) { convexHull( Mat(contours[i]), hulls[i], false ); }

        vector<int> indices(contours.size());
        iota(indices.begin(), indices.end(), 0);

        sort(indices.begin(), indices.end(), [&contours,&hulls](int lhs, int rhs) {
            return contourArea(hulls[lhs]) > contourArea( hulls[rhs]);
        });
        Mat res = Mat::zeros(edge.rows, edge.cols, CV_8UC3);
        int N = 5; // set number of largest contours
        N = min(N, int(contours.size()));



    if(contours.size()==0)
    return;
    drawContours(res, hulls, indices[0], Scalar{255,0,0});
    //hull=hulls[indices[0]];
    contour=contours[indices[0]];
    for (int i =1; i < N; ++i)
        {
            //hull.insert( hull.end(), hulls[indices[i]].begin(), hulls[indices[i]].end() );
            double area=contourArea(hulls[indices[i]]);
            double arc=arcLength(contours[indices[i]], true);
            if((area/arc)>5)
            {
                vector<Point> tmpContour;
                vector<Point> tmpHull1;
                vector<Point> tmpHull2;
                tmpContour.insert( tmpContour.end(), contours[indices[i]].begin(), contours[indices[i]].end() );
                tmpContour.insert( tmpContour.end(), contour.begin(),contour.end() );
                convexHull( Mat(contour), tmpHull1, false );
                convexHull( Mat(tmpContour), tmpHull2, false );
                if((contourArea(tmpHull1)/contourArea(tmpHull2))<0.95&&
                (contourArea(tmpHull1)/contourArea(tmpHull2))>0.8)
                {
                    Scalar color(rand() & 255, rand() & 255, rand() & 255);
                    //drawContours(res, contours, indices[i], color);
                    drawContours(res, hulls, indices[i], color);
                    contour.insert( contour.end(), contours[indices[i]].begin(), contours[indices[i]].end() );
                }
            }
        }
    convexHull( Mat(contour), hull, false );
    if(vis)
    imshow("contour",res);

}

This is what I did.

def findBestContour(edges,contor,hull):

r,c = edges.shape
print(r,c)
_,contours,hierarchy = cv2.findContours(edges,cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
hull =[]
for i in range(len(contours)):
    hull.append(cv2.convexHull(contours[i], False))

indices = len(contours)
indices = range(0,len(contours))
   # p#rint("indices",indices)
res = np.zeros([r,c], dtype='uint8')
N = 5
N = min(N,len(contours))

if(len(contours)==0):
    return 1
cv2.drawContours(res,hull,indices[0],(255,0,0))
contour =contours[indices[0]]
print("contour",contour)
i =1
while i<N:
    area = cv2.contourArea(hull[indices[i]])
    print("area",area)
    arc = cv2.arcLength(contours[indices[i]],True)
    print("arc",arc)
    if((area/arc)>5):



        tmpContour = [] 
        tmphull1 = []
        tmphull2 = []


        _ =[ tmpContour.insert(len(tmpContour),contours[indices[i]][j]) for j in range(len(contours[indices[i]])) ]

         _ =[ tmpContour.insert(len(tmpContour),contour[j]) for j in range(len(contour)) ]

        tmphull1 =(cv2.convexHull(contour,False))
        print("tmphull1",tmphull1)

        if (cv2.contourArea(tmphull1)/cv2.contourArea(tmphull2))<0.95 and (cv2.contourArea(tmphull1)/cv2.contourArea(tmphull2) > 0.8):
            cv2.drawContours(res,hull,i,(255,255,255))
            _ =[ contour.insert(len(contour),contours[indices[i]][j]) for j in range(len(contours[indices[i]]))]

    i=1+i

cv2.convexHull ...
(more)
2018-12-31 13:43:21 -0600 received badge  Scholar (source)
2018-12-29 01:47:42 -0600 received badge  Editor (source)
2018-12-29 01:47:42 -0600 edited question Translating C++ code into python. Facing some problem

Translating C++ code into python. Facing some problem Hello guys, I need your help. I'm trying to translate c++ code in

2018-12-28 18:27:32 -0600 asked a question Translating C++ code into python. Facing some problem

Translating C++ code into python. Facing some problem oid Detection::findBestContour(Mat edge , vector<point> &am