Ask Your Question
-1

Object orientation (horizontal/vertical)

asked 2019-06-12 06:58:23 -0500

Hi All - I am looking for help where i need to identify if the particular object is placed as horizontal or vertical. Did somebody try this?

Thanks, Abhijit

edit retag flag offensive close merge delete

Comments

1

Did somebody try this? -- for sure!

please have a look at the faq and try to improve your question.

berak gravatar imageberak ( 2019-06-12 07:00:32 -0500 )edit

Yes, orientation is a common problem in computer vision. Can you share some images with us?

Chris gravatar imageChris ( 2019-06-12 10:46:09 -0500 )edit

Ok. Please see the image attached. I want to know a) how to find out what's is pen's tip b) what's pen's orientation and what degree w.r.t. horizontal edge of the picture

Thanks, Abhijit

C:\fakepath\IMG_20190621_133255767.jpg

Abhijit B gravatar imageAbhijit B ( 2019-06-21 03:07:59 -0500 )edit
1
sturkmen gravatar imagesturkmen ( 2019-06-21 07:32:01 -0500 )edit

@Abhijit B. Python or c++?

supra56 gravatar imagesupra56 ( 2019-06-23 04:41:57 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-06-21 10:46:24 -0500

Chris gravatar image

OpenCV has a useful tool called PCA (principal component analysis) https://robospace.wordpress.com/2013/... Here is how I used it:

  • resized the image by 1/4 as we don't really need such high resolution here
  • extract the red channel so that the blue part of the pen is darker than the surroundings
  • apply a threshold using binary_inverse with treshold value about 90
  • do some morphology to clean up the threshold image: one iteration of erosion with 3x3 rect and 5 iterations of dilation with 3x3 rect
  • do some contour filtering to only include the contour whose center is nearest the center of the image
  • now do PCA on this remaining contour to give 2 eigenvectors that tell us the orientation

From here, you can apply some test to tell if it is in some desired orientation.

image description

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-06-12 06:58:23 -0500

Seen: 63 times

Last updated: Jun 21