[ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Just starting out? Need help? Post your questions and find answers here.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 625
Joined: Fri Dec 04, 2015 9:26 pm

[ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by skinkairewalker »

hello everyone !
I am doing a research for college, about some reflective balls that are used for movement.
below some pictures of her, can someone help me? if necessary I can even pay!

screenshots :
https://prnt.sc/1249wii
https://prnt.sc/1249x53
https://prnt.sc/1249y58

Videos :
https://drive.google.com/file/d/1mEWCQn ... sp=sharing
https://drive.google.com/file/d/1iFkHkD ... sp=sharing
https://drive.google.com/file/d/1zaqdb8 ... sp=sharing

someone who has knowledge in OpenCV with Purebasic, could you help me?
OpenCV wrapper by JHPJHP in this topic viewtopic.php?f=14&t=57457&hilit=opencv
AAT
Enthusiast
Enthusiast
Posts: 256
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: [ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by AAT »

Hi, skinkairewalker.
You can use the examples in the OpenCV pack as a start point. Forexample, cv_approxpoly_1.pb with small changes:

Code: Select all

...
cvThreshold(*gray, *gray, 210, 255, #CV_THRESH_BINARY)...
...
      For rtnCount = 0 To nContours - 1
        area.d = cvContourArea(*contours, 0, #CV_WHOLE_SEQ_END_INDEX, 0)

;        If area >= 35 And area <= 100000
        If area >= 45 And area <= 1000;000          
          cvDrawContours(*contour, *contours, 255, 155, 0, 0, 155, 255, 0, 0, 0, 1, #CV_AA, 0, 0)
          *poly = cvApproxPoly(*contours, SizeOf(CvContour), *storage, #CV_POLY_APPROX_DP, 5, 1)

;           For rtnPoint = 0 To *poly\total - 1
;             *element = cvGetSeqElem(*poly, rtnPoint)
;             cvCircle(*contour, *element\x, *element\y, 2, 0, 255, 255, 0, 2, #CV_AA, #Null)       
;           Next
          cvMoments(*contours, @moments, 0)
          cx.d = moments\m10 / area
          cy.d = moments\m01 / area
          x = Round(cx, #PB_Round_Nearest)
          y = Round(cy, #PB_Round_Nearest)
          cvCircle(*contour, x, y, 2, 0, 0, 255, 0, 2, #CV_AA, #Null)
          cvCircle(*resize, x, y, 2, 0, 0, 255, 0, 2, #CV_AA, #Null)            
;          cvPutText(*contour, Str(epsilon) + " : " + Str(*poly\total), x + 10, y + 10, @font, 255, 255, 255, 0)
          cvPutText(*resize, Str(x) + "," + Str(y), x + 10, y + 10, @font, 255, 255, 255, 0)          
        EndIf
        *contours = *contours\h_next
      Next
      *param.CvUserData = AllocateMemory(SizeOf(CvUserData))
      *param\Pointer1 = *contour
      *param\Value = window_handle
      cvSetMouseCallback(*window_name, @CvMouseCallback(), *param)

      Repeat
        If *contour
          cvShowImage(#CV_WINDOW_NAME, *contour)
          cvShowImage("Pic", *resize)
          keyPressed = cvWaitKey(0)
        EndIf
      Until keyPressed = 27 Or exitCV
...      
   
The picture captured from WhatsApp Video 2021-04-16 at 16.50.01.mp4:
http://images.vfl.ru/ii/1619533982/3436 ... 245821.bmp
The result is:
http://images.vfl.ru/ii/1619534266/0f1f ... 245993.png
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 625
Joined: Fri Dec 04, 2015 9:26 pm

Re: [ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by skinkairewalker »

Wooow, awesome !!
Thanks a lot for the help !!!!!
AAT
Enthusiast
Enthusiast
Posts: 256
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: [ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by AAT »

More pictures.
The picture captured in "WhatsApp Video 2021-04-16 at 18.57.48.mp4":
http://images.vfl.ru/ii/1619580768/10ac ... 251232.bmp
The result is:
http://images.vfl.ru/ii/1619580797/8b8c ... 251234.png

P.S. You should to remove all the bright and glaring details of the environment from the frame. For example, the brake lever on the handlebars of the exercise bike.
Você deve remover todos os detalhes brilhantes e gritantes do ambiente do quadro. Por exemplo, a alavanca do freio no guiador da bicicleta estática. :)

P.P.S Do you have an idea how to connect the dots to make a skeleton?
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 625
Joined: Fri Dec 04, 2015 9:26 pm

Re: [ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by skinkairewalker »

Thank you immensely AAT

I would like to ask another question, is it possible to make the webcam capture these glowing spheres in real time?
AAT
Enthusiast
Enthusiast
Posts: 256
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: [ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by AAT »

Hi, skinkairewalker.
Yes, it's possible. The JHPJHP's OpenCV package contains many examples of processing images from a webcam or from a movie in real time.
You need:
1 capture video frame
2 execute the image processing algorithm
3 show the processed frame
4. goto 1 :)

Forexample:
1. captured and processed frame from your video (the face in this picture was blurred in another program before publishing):
Image
2. processed video (19.5 MB)
https://disk.yandex.ru/i/CCkH9mXQRnvY-A
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 625
Joined: Fri Dec 04, 2015 9:26 pm

Re: [ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by skinkairewalker »

could you send me the ready example of how you captured this video? I don't know anything at all about openCV, if you could give me a "light", I would appreciate it immensely, if you prefer, I can even pay you to provide the example.
AAT
Enthusiast
Enthusiast
Posts: 256
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: [ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by AAT »

Yes of course.
I will put the code in PureBasic Interface to OpenCV theme
https://www.purebasic.fr/english/viewto ... &start=855

I would like to get permission to use your video in the examples for this package.
AAT
Enthusiast
Enthusiast
Posts: 256
Joined: Sun Jun 15, 2008 3:13 am
Location: Russia

Re: [ OpenCV Question ] does anyone know how i detect these reflective balls with openCV?

Post by AAT »

Post Reply