Making a GUI for Aligning Feeder Positions and Saving the Values to a CSV file

More
14 Aug 2022 15:23 #249720 by my1987toyota
    This is a bit of an ambitious one for me I want to make a GUI and put in a selectable tab on Linuxcnc so I can
use the on board down look camera to align the feeders then save the positions to the Feeders CSV file.

The challenges needing to be addressed
1 Getting familiar with Gladevcp
2 make a small DRO display with the G53 Machine Coordinate System output while in the Feeders tab
3 make a Jog control in the tab to control the X, Y,  Z, and C axis while aligning
4 have a window that displays the real time down look camera image with cross hairs.
5 When the X and Y position is written to the Feeders CSV file it will apply an offset so while running a PnP program
   the picking head will be over the feeder component instead of the camera.
6 When the down look Camera is selected for feeder alignment it will use the saved X and Y position plus the camera offset
   so the camera will be over the top of the Feeder component to be aligned.
7 When aligning the Z axis the feeder head will move to the X and Y position of the component and allow G53 Z height to
  be set and saved to the Feeder CSV file
8 Allow the use of an external MPG pendant while in the Feeders Tab

That's all I can think of for now. I am hoping I can actually get it to the ultimate form of having the machine use the camera to
auto align the X and Y positions of the feeders. For now though I need a manual way of doing it. One step at a time.
 

Please Log in or Create an account to join the conversation.

More
20 Aug 2022 23:24 - 21 Aug 2022 12:44 #250136 by my1987toyota
  This week has been a busy week so I haven't been able to accomplish much
 in way of the pick and place. That said I did make some head way with Opencv.
I wrote a simple Python and Opencv program that uses a usb camera and
places a Red cross-hair on the picture. I have a long way to go to get a working
Glade gui but one step at a time.
 I have been looking over dm17ry's vision and configuration and using that to get
a good starting point.

 In my next post I will be placing my Python / Opencv code in text format for
ease of readability. If you wish to test out the program you will need to
go into synaptic package manager and install python opencv if you don't have
it on your computer already. As far as cameras go I am using an
ELP-USB100W03M-L36 . I am placing the Python file for down load as well.
If you run the program and want to exit press the 'q' key on the keyboard.
Last edit: 21 Aug 2022 12:44 by my1987toyota. Reason: adding info

Please Log in or Create an account to join the conversation.

More
20 Aug 2022 23:26 #250137 by my1987toyota
import cv2 as cv

cap = cv.VideoCapture(0);

cap.set(3, 360)
cap.set(4, 360)
print(cap.get(3))
print(cap.get(4))
#cap.set = 720 X 720
#3 = 600 = 300
#4 = 800 = 400
#
#cap.set = 360 X 360
#3=352.0 = 176
#4=288.0 = 144

while(True):
    ret, frame = cap.read()

#    horz = cv.line(frame, (0, 300), (800, 300), (0, 0, 255), 1)
    horz = cv.line(frame, (0, 144), (352, 144), (0, 0, 255), 1)
    
#    vert = cv.line(frame, (400, 0), (400, 600), (0, 0, 255), 1)
    vert = cv.line(frame, (176, 0), (176, 352), (0, 0, 255), 1)
    
    cv.imshow('Top_CamView', frame)
    
    if cv.waitKey(1) & 0xff == ord('q'):
        break
        
cap.release()
cv.destroyAllWindows()



 

File Attachment:

File Name: camera-vie..._Hair.py
File Size:1 KB
Attachments:
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

More
14 Oct 2022 10:38 #254108 by my1987toyota
Well I have had to put this idea on the sideline for now. I will come back to it at some other time
just life as usual has changed my schedule.

Please Log in or Create an account to join the conversation.

More
26 Nov 2022 21:27 #257702 by cakeslob
Hey, Ive been meaning to work on this and Dmitry's up camera, but before that I needed to build/install/configure my hardware with c axis before I started on this.

Nothing against qt/glade, but for simplicity I am trying to do everything in an Axis tab with tk/tcl/tkinter, and probably using usercommand file so that is my challenge.

The usercommand file Ive included is your initial file, but with a camera tab created in axis. I am using this as a starting point.

first hurdle : conflicting mainloops between axis and opencv

here is solutions, but Im trying to understand them first (I struggle with OOP)

stackoverflow.com/questions/72318466/how...ow-inside-tkinter-ui
github.com/furas/python-cv2-streams-viewer
Attachments:
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
04 Dec 2022 01:18 #258469 by my1987toyota
thanks cakeslob I will check it out when I can I am slammed at work so I haven't been able
to work on this specific project in a while.

Please Log in or Create an account to join the conversation.

More
04 Dec 2022 02:15 #258472 by cmorley
I know you said you want to use tcl but Qtvcp can be embeded into AXIS and has a camview panel that uses opencv.
The following user(s) said Thank You: my1987toyota

Please Log in or Create an account to join the conversation.

More
04 Dec 2022 06:38 #258479 by cakeslob
Yeah, I will need to learn to choose my battles better.
I couldnt make any progress on this or other things because I have been using buster until now and stuff has stopped working, so I have been setting up my new bullseye so things work again.

good point Chris, Im not smart enough to re-invent this wheel. Camview worked fine on rpi4, but qtvcp also looks hard as shit if Im not just moving things around in qtdesigner
If I want a camview qtvcp tab to do fancy things like Dmitry's auto align pnp stuff seen here github.com/yur7aev/linuxpnp/blob/master/configs/pnp/vision.py

Would I replace gtk with qt and jam this into my camview handler file, or would I need to make any machine vision related changes to the camview_widget?

Please Log in or Create an account to join the conversation.

Time to create page: 0.209 seconds
Powered by Kunena Forum