Ask Your Question
0

How to Shift a rect by a certain offset in openCV4Android

asked 2014-09-30 10:44:46 -0600

HasanGhaforian gravatar image

Here,opencv docs say:

In addition to the class members, the following operations on rectangles are implemented:

rect = rect + point (shifting a rectangle by a certain offset)

...

I want to use this in openCV4Android.So I did like this:

Rect r = new Rect(...);
r + new Point(4,5);

But this error occurs:

Type mismatch: cannot convert from Point to Rect

Did I do wrong or it (shifting a rectangle by a certain offset in openCV4Android) or it is not possible and I have to declare Rect again?

edit retag flag offensive close merge delete

Comments

sorry, but this is a c++ feature only (there are no overloadable operators in java)

berak gravatar imageberak ( 2014-09-30 10:49:22 -0600 )edit

@berak So can I calculate new coordinates and use r.set(new double[4]) instead of that?If yes,is it better than this: r = new Rect(...)? thank you.

HasanGhaforian gravatar imageHasanGhaforian ( 2014-09-30 11:01:18 -0600 )edit

wouldn't it be simply: r.x += 4; r.y += 5; ?

berak gravatar imageberak ( 2014-09-30 11:05:37 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-09-30 23:51:07 -0600

HasanGhaforian gravatar image

@berak OK! Can you write your response as answer? So I can accept it as correct answer.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-09-30 10:44:46 -0600

Seen: 1,790 times

Last updated: Sep 30 '14