Ask Your Question

muntianucristian's profile - activity

2015-05-25 14:56:25 -0600 commented question Imgproc.getRectSubPix not working/giving errors

Found the answer, will post it tomorrow(can't post it now)

2015-05-25 13:52:37 -0600 commented question Imgproc.getRectSubPix not working/giving errors

Well, posted the message i got, should i print the stacktrace too? Also sorry for jumping on ya, first time i request help online, and i'm used with trolls from gaming :D

2015-05-25 13:26:03 -0600 commented question Imgproc.getRectSubPix not working/giving errors

Aham, this is your ideea of a constructive "comment" ? Can you help me or you just came here hoping u get free coment points?

2015-05-25 13:09:37 -0600 commented question Imgproc.getRectSubPix not working/giving errors

Added a link to stackoverflow with a similar thing and ther you have the logs. http://stackoverflow.com/questions/28...

2015-05-25 13:09:07 -0600 received badge  Editor (source)
2015-05-25 11:58:51 -0600 asked a question Imgproc.getRectSubPix not working/giving errors

PS:Sorry for reposting, but i get internal server error when i try to see my last post.

I work on a thesis and for 3 days consecutive i'm held back by an error in my code that , for the love of god, can't seem to fix it.

The ideea is simple, i have a map with 3 black corners(exactly like the QR code). I get the 3 black corners center coordinates and the last point's coordinate(Point D) I want to exctract this area to a file in a way to have the map always pointed at an agnle of 0, 90, 180, 270,360 degrees. I've searched the internet and found a solution involving RotatedRectangle. Here's some code that works :

public static RotatedRect getRotatedRect(List<Point> orderedPointList, Point D){// here i have as parameters Points(in this order) Top Right and Bottom + the final calculated point(Point D);
    if(orderedPointList==null)
        return null;
    RotatedRect rect = new RotatedRect();
    Point Top = orderedPointList.get(0);
    Point Right = orderedPointList.get(1);
    Point Bottom = orderedPointList.get(2);
    Point[] points= new Point[]{Top,Right,D,Bottom};
    rect.points(points);
    Point Center = new Point();
    Center.x=(Bottom.x+Right.x)/2;
    Center.y=(Bottom.y+Right.y)/2;
    rect.center = Center;
    double diference1=Top.x-Bottom.x;
    double difference2=Top.y-Bottom.y;
    double angle=Math.atan(diference1-difference2) * 180/Math.PI;// this formula is used to see how much the map is rotated untill now i haven't tested it for all degrees but as i see it returns -180 0 180.
    rect.angle=angle;
    double mapwidth=Math.sqrt((Right.x-Top.x)*(Right.x-Top.x)+(Right.y-Top.y)*(Right.y-Top.y));
    double mapheight=Math.sqrt((Bottom.x-Top.x)*(Bottom.x-Top.x)+(Bottom.y-Top.y)*(Bottom.y-Top.y));
    rect.size.width=mapwidth;
    rect.size.height=mapheight; // here i set the RotatedRectangle width and height.
    return rect;
}

The following code, however doesn't work no matter what i do:

public static Mat getRotatedRectMat(Mat mImage,RotatedRect rect){
    if(rect==null)
        return null;
     Mat M  = new Mat();
     Mat rotated = new Mat();
     Mat clone=mImage.clone();
     //clone.convertTo(clone, CvType.CV_32F);
     //rotated.convertTo(rotated, CvType.CV_32F);
     // perform the affine transformation
     Rect boundingRect = rect.boundingRect();
     if(boundingRect.x >= 0 && boundingRect.y >=0
             && (boundingRect.x+boundingRect.width) < clone.cols() &&  
               (boundingRect.y+boundingRect.height) < clone.rows() ){
         Mat cropped=new Mat();
         M = Imgproc.getRotationMatrix2D(rect.center, rect.angle, 0.5);
         Imgproc.warpAffine(clone, rotated, M, clone.size(), Imgproc.INTER_AREA);
         Imgproc.getRectSubPix(rotated, rect.size, rect.center, cropped);//CRASHES exactly right here
reason:Noone knows
         return cropped;

     }

Some thing's i've tried from stackoverflow& other sites: http://stackoverflow.com/questions/28... How do I calculate relative time?... - this is the closest result i'd want to get but i have no ideea how to do it in OpenCV4Android

Edit: Did a trycatch on the error, here's the error message cv::Exception: /home/reports/ci/slave_desktop/50-SDK/opencv/modules/imgproc/src/samplers.cpp:556: error: (-210) in function void ... (more)

2015-05-25 11:48:47 -0600 asked a question [OpenCV4Android] Imgproc.getRectSubPix() giving errors.

Hello, I work on a thesis and for 3 days consecutive i'm held back by an error in my code that , for the love of god, can't seem to fix it.

The ideea is simple, i have a map with 3 black corners(exactly like the QR code). I get the 3 black corners center coordinates and the last point's coordinate(Point D) I want to exctract this area to a file in a way to have the map always pointed at an agnle of 0, 90, 180, 270,360 degrees. I've searched the internet and found a solution involving RotatedRectangle. Here's some code that works :

public static RotatedRect getRotatedRect(List<Point> orderedPointList, Point D){// here i have as parameters Points(in this order) Top Right and Bottom + the final calculated point(Point D);
    if(orderedPointList==null)
        return null;
    RotatedRect rect = new RotatedRect();
    Point Top = orderedPointList.get(0);
    Point Right = orderedPointList.get(1);
    Point Bottom = orderedPointList.get(2);
    Point[] points= new Point[]{Top,Right,D,Bottom};
    rect.points(points);
    Point Center = new Point();
    Center.x=(Bottom.x+Right.x)/2;
    Center.y=(Bottom.y+Right.y)/2;
    rect.center = Center;
    double diference1=Top.x-Bottom.x;
    double difference2=Top.y-Bottom.y;
    double angle=Math.atan(diference1-difference2) * 180/Math.PI;// this formula is used to see how much the map is rotated untill now i haven't tested it for all degrees but as i see it returns -180 0 180.
    rect.angle=angle;
    double mapwidth=Math.sqrt((Right.x-Top.x)*(Right.x-Top.x)+(Right.y-Top.y)*(Right.y-Top.y));
    double mapheight=Math.sqrt((Bottom.x-Top.x)*(Bottom.x-Top.x)+(Bottom.y-Top.y)*(Bottom.y-Top.y));
    rect.size.width=mapwidth;
    rect.size.height=mapheight; // here i set the RotatedRectangle width and height.
    return rect;
}

The following code, however doesn't work no matter what i do:

public static Mat getRotatedRectMat(Mat mImage,RotatedRect rect){
    if(rect==null)
        return null;
     Mat M  = new Mat();
     Mat rotated = new Mat();
     Mat clone=mImage.clone();
     //clone.convertTo(clone, CvType.CV_32F);
     //rotated.convertTo(rotated, CvType.CV_32F);
     // perform the affine transformation
     Rect boundingRect = rect.boundingRect();
     if(boundingRect.x >= 0 && boundingRect.y >=0
             && (boundingRect.x+boundingRect.width) < clone.cols() &&  
               (boundingRect.y+boundingRect.height) < clone.rows() ){
         Mat cropped=new Mat();
         M = Imgproc.getRotationMatrix2D(rect.center, rect.angle, 0.5);
         Imgproc.warpAffine(clone, rotated, M, clone.size(), Imgproc.INTER_AREA);
         Imgproc.getRectSubPix(rotated, rect.size, rect.center, cropped);//CRASHES exactly right here
reason:Noone knows
         return cropped;

     }

Some thing's i've tried from stackoverflow& other sites: http://www.tech.theplayhub.com/imgpro... http://stackoverflow.com/questions/11... - this is the closest result i'd want to get but i have no ideea how to do it in OpenCV4Android