No video

Auto-Measuring with OpenCV + Python - Try It Yourself

  Рет қаралды 84,442

Clayton Darwin

Clayton Darwin

Күн бұрын

UPDATE: I added defaults and a config file where you can save your settings. See lines 19 and 40 in the new code.
Fooling around with OpenCV and Python to measure stuff with a single camera. Automatic for the people. Try it out: gitlab.com/dud...
Camera: • New Camera Module - Un...

Пікірлер: 274
@lassefrost6198
@lassefrost6198 14 сағат бұрын
For performance improvement i would recommend background subtraction and after that pixel summing/tresholding as a frame skipping condition. You can further improve it by only analysing the parts of the picture that passes a binary mask based on the same summing/treshold. Beware that the background subtraction works best in tandem with frameaveraging into treshold that creates the binary mask, otherwise you get noise into your mask :)
@chrisdowdle1
@chrisdowdle1 3 жыл бұрын
Clayton. This is just fantastic. Thank you so much for putting this stuff up for all to learn from. Cheers from a 'Land Downunder'. If I could give a million thumbs up I would.
@mkaberli
@mkaberli 2 жыл бұрын
I don't know what was going through the minds of the people who rated this video with a thumbs down, but I, like a host of others, appreciate your making these videos.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Thanks, boss.
@DaveWheeler
@DaveWheeler 3 жыл бұрын
Thank you Clayton! Especially for sharing the code. For anyone who wants to write the lengths file, the variables are ylen, xlen at #503-508ish in camruler.py. If it outputs too much data maybe adjust line 360 'time.sleep(0.1)' to something bigger? Another cheers from Down under.
@richardwoodza
@richardwoodza 3 жыл бұрын
This is awesome, I appreciate your work and thank you for sharing this with us. Love the way it runs, so smoothly :). Again, thank you a lot for sharing, this help me a lot to keep learning.
@lehnertak
@lehnertak 3 жыл бұрын
Nice Project! Thanks for making this available for those of us learning. I hope to use this to measure the size of peony flowers this summer for my girlfriend's small flower farm. She will think I am a genius!!
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Nice! Hey, are those your CNC tools in your videos? Do you have a CNC shop?
@lehnertak
@lehnertak 3 жыл бұрын
@@ClaytonDarwin I set up a high end MakerSpace for a school in Shanghai the last five years. Couldn't get back because of Covid--so now I only have my own 3D printer, cricut cutter and Maslow CNC router to play with. Need to find another school to set up here in the States.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Very cool. Did you see my recent SCARA plotter ( kzfaq.info/get/bejne/mtCpgMSitb-UpIU.html ). I was trying to come up with something that anybody could build (i.e. teenagers). I would like to develop that more and do some other education-oriented projects at some point. Working on an ESP32 funboard at the moment (in my spare time).
@lehnertak
@lehnertak 3 жыл бұрын
@@ClaytonDarwin Your plotter is nice. I had just started working with the Chinese Homework Machine and was going to have kids try and make one of them. www.scmp.com/yp/discover/entertainment/tech-gaming/article/3060907/chinese-schoolgirl-caught-using-robot-write It is another simple plotter that costs about $100 over there. A clever mechanism for x-y motion.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I've seen those. Haven't had time to make one.
@abu8422
@abu8422 2 жыл бұрын
Thank you Clayton! Especially for sharing the code. and how to find the object`s center point and the farthest distance from the center point
@boultifnidhal2600
@boultifnidhal2600 6 ай бұрын
That was really helpful, thank you so much, keep up the great work.
@wsumardji
@wsumardji 3 жыл бұрын
This is awesome. if you have more time it will be very good if you make series tutorial of camera measurement of any object, for example key measurement as the object to measure the length and the height of each part of the key like the notches depth, the ridges height, the shoulder distance etc. Thank you very much.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Good idea. I haven't had time lately to return to this project. But this can certainly be a template for a more complex project like what you are describing.
@talha_anwar
@talha_anwar 3 жыл бұрын
Too much satisfactory to watch this
@markpretorius6854
@markpretorius6854 3 жыл бұрын
Well done Clyton. Good job and thanks
@blazecoolman
@blazecoolman 3 жыл бұрын
This is awesome. Thank you so much for this. Could you please make a video about the how you plan the architecture for a project like this?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Thanks. Glad you like it. I'm not sure about an architecture video. I'm self-taught for the most part, so I don't have much theory. I just work in parts, getting each function to work correctly, and then try to combine them into a logical, orderly, and efficient whole. I re-write many times, and I often write my own wrappers and libraries if the ones available don't do what I want. Lots of trial and error. Lots of failures. Lots of reading. Lots of Google queries.
@sibujacob977
@sibujacob977 2 жыл бұрын
Beautifully explained !!
@rodrigca22
@rodrigca22 3 жыл бұрын
Hi Clayton, very interesting project, would you please elaborate on the logic on how the menu system works. Your code is very neat and tidy, superb!
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I'll have to go and look at it. Can't remember off hand.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
All events are handled by either the key_event() or mouse_event() functions. The mouse event function must be registered as a callback, while the key event function can be called at the bottom of the main loop. The event functions basically read event data a set global variables. The main loop, then uses the variables to decide what action to perform (and also what values the use).
@vishwasvishu1895
@vishwasvishu1895 2 жыл бұрын
sir can we try this projects using our phone cameras instead of webcam because I am finding difficult to afford the webcam
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
I have never used a phone camera as a webcam, but one of my subscribers said it was possible.
@antonioviciana3733
@antonioviciana3733 2 жыл бұрын
Nice work Clayton!!! I was wondering how can you implement real time angle meauserement in this project ??
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
You would have to identify 3 points and then do a little trigonometry. OpenCV has quite a few options for things like that.
@daddytolentino3540
@daddytolentino3540 6 ай бұрын
Cool, I'm glad i get to watch this!. is it possible to rewrite or just add the code and measure the circumference of the circle?
@ClaytonDarwin
@ClaytonDarwin 6 ай бұрын
Yes. Any distance could be treated like a diameter and multiplied by pi.
@kevinlcarlson
@kevinlcarlson 3 жыл бұрын
I just bought a webcam with a built-in ring light, to help prevent shadow issues. Also, am experimenting with round stickers at each corner of the white background sheet. Since these have a fixed diameter, circular object diameter can be measured as a percentage of the diameter of the round stickers, then actual size and position can be calculated even when the camera is moved, by constantly recalculating positions and sizes in a live video stream. Have you tried anything like this?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Two good ideas. 👍 The lens distortion is fixed, so once you have it calibrated, you should be able to adjust based on the stickers. I think.
@prajwalkn9726
@prajwalkn9726 2 жыл бұрын
Sir are you directly connecting camera to usb, or using any boards in btw? Thank you in advance...
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Direct connect.
@prajwalkn9726
@prajwalkn9726 2 жыл бұрын
@@ClaytonDarwin sir I am new to this, @6:15 and @6:40, which software prompt is that?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Linux command line or python are the two options.
@mileswilson3612
@mileswilson3612 2 жыл бұрын
hey, I'm struggling to import frame capture and draw, how do I install these libraries?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Did you install opencv for python?
@thiagosantos8674
@thiagosantos8674 5 ай бұрын
Hello, I would like to measure some cylindrical rock samples, in order to know which is the shortest side of the cylinder if the sample is broken and the broken face is diagonal. It would be a kind of irregular polygon where one side would be smaller. How do I make the code create an outline and identify the shortest side, putting the measurement in centimeters?
@ClaytonDarwin
@ClaytonDarwin 5 ай бұрын
Probably you could use opencv to detect edges/lines, or possibly a closed polygonal shape, and then build your dimensions from that. That's the way I would start tackling the problem.
@MiguelRodriguez-wn8mc
@MiguelRodriguez-wn8mc Жыл бұрын
Hello, it's very nice. Your development seems to work very well with square and rectangular objects. Now, what happens if the object doesn't have that shape? For example, a wood shaving, a small piece of paper cut by hand, some shapeless pieces of plastic.
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
Like the title says, "try it yourself" and then you will know what it can do. Then you can take the code and improve it.
@muhammadrezap3222
@muhammadrezap3222 7 ай бұрын
Hello sir, I'm a beginner in software programming and I'm interested in the measurement program you created. I've also accessed the program file through Git Hub. but in the program, I'm confused about how the steps are taken to get the actual unit of measure. can you explain it to me?
@ClaytonDarwin
@ClaytonDarwin 7 ай бұрын
The unit of measure depends on what measure you use during calibration. In the example I used mm.
@anonimov9107
@anonimov9107 Жыл бұрын
That should be interface for engraving fiber laser program.. Would be awesome
@trexieramirez3975
@trexieramirez3975 6 ай бұрын
Hi! What camera module you used for that?
@ClaytonDarwin
@ClaytonDarwin 6 ай бұрын
Any that will work on your system. I've used several.
@suwei-fx6ib
@suwei-fx6ib Жыл бұрын
大叔这么厉害 这视频真的是太棒了
@michaelandersen1161
@michaelandersen1161 3 жыл бұрын
Hello clayton Nice video, Can you Tel what camera and Lense you Are using for This project? Also what version of openmv Are you using?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I have a USB3 camera somebody sent to me. I think it's 1080p, up to 60fps. There is a video about it. I pit an adjustable lens on it, and it was probably set at about 22-25mm. But pretty much anything will work.
@jacobmenture8657
@jacobmenture8657 2 жыл бұрын
Hey Clayton - Amazing work!! Do you know the equivalent command for windows to check on the camera ID piece by chance?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Sorry. Haven't messed with windows for a while. Isn't there a devices list?
@bsinelnikov
@bsinelnikov 3 жыл бұрын
Thank you for your helpful lesson! Could you please recommend which camera is better to use for this task and generaly for computer vision? Thank you in advance.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Any USB camera will work. Higher resolution allows more accuracy. Also, I like CS-mount cameras because they give you a lot of high-quality lens choices.
@bsinelnikov
@bsinelnikov 3 жыл бұрын
@@ClaytonDarwin How do you zoom in the image in your video? Is it optical zoom or just digital one?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
In the video I use digital zoom. It's a feature of an OpenCV window. Will zoom to the sub-pixel level. If you change your zoom manually, you will have to re-calibrate your camera.
@ColJack100
@ColJack100 Жыл бұрын
Dear Clayton, this is an amazing video! I would like to use a camera to detect twp things: a fiber tip and the edge side of a metal plate. Could you give me a tip how to make the image recognition best?
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
Sorry for the late reply. You could definitely add edge detection or image recognition to this using opencv. The best results will be had by closely controlling the environment and lighting to get a clear image.
@oumaymabourass4829
@oumaymabourass4829 3 жыл бұрын
good video, I appreciate your work. I've a question please, how can I reduce the size of the window which displays the camera's view, because it appears only a part of the writing of modes and configurations... please respond as soon as possible.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
You can change it with an OpenCV parameter, or by changing the camera resolution. Or by dragging the frame corner with your mouse.
@oumaymabourass4829
@oumaymabourass4829 3 жыл бұрын
@@ClaytonDarwin which parameter of OpenCV
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Try googling "OpenCV python change window size".
@al_khuzai
@al_khuzai Жыл бұрын
Thank you Clayton! I'm just wondering what is the precision of measurement? Is it more than ± 0,1 mm?
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
Accuracy depends on the camera pixel count, the lens, and how well you calibrate.
@juliendesmangles1050
@juliendesmangles1050 11 ай бұрын
Great video! You currently rely on a known distance between the camera and the object to identify the dimensions of the object. Would it be feasible to modify the program to infer a distance between the camera and the object if the dimensions of the object are known?
@ClaytonDarwin
@ClaytonDarwin 11 ай бұрын
Sure. Same math, just using different variables.
@mikecoxiii
@mikecoxiii Жыл бұрын
I LOVED THE TUTORIAL. However what units are objects measured in?
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
Whatever you use during the calibration, that's what it is.
@sswamy9862
@sswamy9862 3 жыл бұрын
Hii, great video, Is this code works on windows, vscode ?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I do not know. I only work on Linux.
@mitchwright1558
@mitchwright1558 2 жыл бұрын
Hi Clayton, This is very piratical and informative, can you point toward references on the topic? BTW, I like these technical topics but I miss the interesting gizmos you build... Cheers, Mitch
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Hi Mitch. I don't really have any specific references other than the OpenCV docs. I do lots of googling and reading, and then go back to the docs.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Yeah. You're right. I need to get back to making stuff. I've just been really busy with work the last couple of years and not able to spend as much time in the shop. But making goofy robots is what I like to do. Thanks for reminding me.
@MatheusSilva-qm3ph
@MatheusSilva-qm3ph 3 жыл бұрын
Very good video congratulations. A question, I have a .png image and I would like to find a frame that has it and see how far from the edge of the image is to the edge of the square. Can you make a video helping me? Thanks
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Unfortunately, I don't have the time to investigate this at the moment.
@MatheusSilva-qm3ph
@MatheusSilva-qm3ph 3 жыл бұрын
@@ClaytonDarwin ok, thanks.
@lamvinh98
@lamvinh98 3 жыл бұрын
Awesome project.
@patis.IA-AI
@patis.IA-AI Жыл бұрын
Hello Dear , thanks for the video. Little problem when I hit the A key my scrren frezes up ! Anny idea please ?
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
No idea. I was using it the other day and it worked fine on my setup. Might be that you have a different key binding for A .
@nurazizahbahraeni4545
@nurazizahbahraeni4545 3 жыл бұрын
Hello Clayton, ive a question and may you would like to answer, if i use 2 cameras which one for detect and measure reference object and other one for detect and measure another object that i wanna know that dimensions, could it be working on? I wanna make the camera which detect object measure can be adjustable
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I think you can combine the ideas in this video with the ideas in my triangulation video and do what you are describing. I haven't done it, but I have thought about it.
@nurazizahbahraeni4545
@nurazizahbahraeni4545 3 жыл бұрын
@@ClaytonDarwin i wanna make it for my final project in school, thanks for your info. But now I'm stuck on how to use a USB camera when I've done put it in port USB, because when I tried your code I can't change the camera set, please let me know which code that I have to change for setting the camera to camera USB, not camera laptop webcam?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
You have to edit the code and set the camera number according to your setup. This is an OpenCV setting.
@sktrimline
@sktrimline 3 жыл бұрын
Due to the nature of video analysis, measurements often change slightly. Is there any way to correct this part?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Higher resolution cameras, better camera calibration, better lighting (and contrast adjustments). Those are main factors that affect measurement.
@kevinlcarlson
@kevinlcarlson 3 жыл бұрын
@@ClaytonDarwin I've seen some document cameras on Amazon that apparently compensate for the distortion issue. These have much higher resolution than most web cams and can focus very closely. On the down side, the depth of field is not great, i.e. these are mostly suited for relatively flat objects such as books or other documents.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Interesting. Might work in this situation.
@nurazizahbahraeni4545
@nurazizahbahraeni4545 3 жыл бұрын
Hallo clayton i have a question, from this video why you don't use reference object?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
A small reference object assumes that the frame has already been normalised, which is what we are doing with the measurements. Once the frame is normalised, you could use a reference object. Alternatively, you could use a full-frame reference object to normalize the frame. I don't like the one in OpenCV, and I didn't have time to write one myself the day I made this video. This code is just an example, not a product.
@farigul191
@farigul191 3 жыл бұрын
Clayton when will you make the real-time object measurement video I am stuck that how to measure the distance from camera using opncv and pytorch?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Distance from camera generally requires 2 cameras unless the target object is of a know size. Like my triangulation video. Also, this script is real time. You can make it an iterator and yield the data rather than plot it if you need to.
@YazeedAlkosai
@YazeedAlkosai 3 жыл бұрын
Dearest Clayton Darwin ; could I use this code for my purpose of measuring objects?. Is it working in windows? thanks in advance
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Excellent. Yes. Use it however you like.
@YazeedAlkosai
@YazeedAlkosai 3 жыл бұрын
@@ClaytonDarwin thanks with full respect dear
@azhagarasonb5588
@azhagarasonb5588 2 жыл бұрын
Excellent video sir. Iam trying with a PTZ camera (analog). Which line in the program will call camera function? By default whether the program takes Laptop camera (inbuilt)? Thanks many
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
The camera is defined in OpenCV by a number. You can change that near the top of the script. It is marked with a comment.
@PabloLucio
@PabloLucio 9 ай бұрын
Could this be used for measuring people's arms length, leg lenghts, etc in real time or from an image?
@ClaytonDarwin
@ClaytonDarwin 9 ай бұрын
This uses geometry/trigonometry to calculate distances based on a known distance (the distance from camera to table). You can use a similar algorithm to do the measurements you describe as long as you have a known distance to target measurement.
@lassefrost6198
@lassefrost6198 14 сағат бұрын
@@ClaytonDarwin You can also build it as relational measurement between height x width / arms x legs. This should be relational to what you are looking for as long as people have all their limbs :) :)
@banraisamluang
@banraisamluang Жыл бұрын
Hey Clayton thank you for you file How i can add the capture mode with photos had included detail of x,y axis and width,length of object and then save into our drive?
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
Do you know how to program? You would have to change the code.
@oumaymabourass4829
@oumaymabourass4829 3 жыл бұрын
Hello, please I want to fix the configurations that we set every time we execute the code. ( I mean the measures of each part of "cal_rang" ) could you help me.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
When you do the configuration the first time, the program should create a configuration file. This is loaded on start, so you should not need to reconfigure unless the camera setup changes.
@oumaymabourass4829
@oumaymabourass4829 3 жыл бұрын
@@ClaytonDarwin could you explain more please? what is the type of this file (filename.what?)
@oumaymabourass4829
@oumaymabourass4829 3 жыл бұрын
@@ClaytonDarwin when I did the configuration, only one excel file that was created, is this what you mean?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Please read the file: gitlab.com/duder1966/youtube-projects/-/blob/master/OpenCV/camruler/camruler.py#L118
@oumaymabourass4829
@oumaymabourass4829 3 жыл бұрын
@@ClaytonDarwin I found the file, thanks.
@Werbewunder
@Werbewunder 3 жыл бұрын
Hi Clayton, I would like to install your project on an ESP32 cam. My question is it possible?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
There isn't a simple solution for something like that. You would need something similar to the OpenCV library to do the object detection and image manipulation, but a very reduced and streamlined version to run on the ESP32. I haven't seen anything like that. Memory is going to be a problem. Most image libraries want to hold a full image in memory in order to work on it.
@Werbewunder
@Werbewunder 3 жыл бұрын
Thank you for the quick reply. Then I will try it with the PI 4. Maybe you can make a video how to install everything exactly in what order. Please continue to do so that helps many users who are not so fit with the software
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I've never tried it, but I think a Pi4 should work, although you might not get as high of a frame rate as you could on a larger machine.
@user-nf8le2lv7r
@user-nf8le2lv7r 6 ай бұрын
hello sir, I apologize in advance if my English pronunciation is lacking. I would like to ask about the automatic measurement program. especially in the camruler_cal.csv file. I understand that the conversion process is carried out for every 10 pixels based on pixel_base = 10. but I am confused, where are the pixel and scale values in the .csv file obtained from?
@ClaytonDarwin
@ClaytonDarwin 6 ай бұрын
When you do the calibration the file is created.
@user-nf8le2lv7r
@user-nf8le2lv7r 6 ай бұрын
@@ClaytonDarwin However, if I use your program on Git Hub, the .cv file already exists. This means that if I rewrite all your programs, so that mean a new .csv file will be created containing pixel and scale data for calibration?
@ClaytonDarwin
@ClaytonDarwin 6 ай бұрын
Whenever you do the calibration a new calibration file is created.
@ClaytonDarwin
@ClaytonDarwin 6 ай бұрын
The other csv file is the setup variables.
@user-nf8le2lv7r
@user-nf8le2lv7r 6 ай бұрын
The calibration do you mean is a measurement to get the cal_range value in config mode?
@abomination.3005
@abomination.3005 2 жыл бұрын
Hello sir, I want to measure the dimensions of a multi-sized object in one with the measurement frame still in which line do I need to edit?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
This is just a demo script. You will need to write your own to adapt to a specific task.
@ChrisDembinsky
@ChrisDembinsky 2 жыл бұрын
I'd like to do something like this from a distance but get the GPS location of the pixels instead of their size. Do you think it can be done?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
I think so. With a single camera you will need a fixed reference point some exact distance from the camera, and then I think you can work out the distances as done in this video using some trig/geometry. You could then convert it to GPS coordinates from a known point.
@beyse101
@beyse101 Жыл бұрын
Why don’t you use an edge detector? That is how you detected edges. It’s really simple.
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
Please share your code with us.
@mariorodrigues1888
@mariorodrigues1888 3 жыл бұрын
Nice video, i'm a beginner on python, and i have a project that is pretty similar, but my camera doesnt connect, so i'm trying to use my phone trough a Ip webcam, is it possible to apply the same functions ? Keep the good job, waiting for an answer ✌
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I don't know the answer. I've never used a phone as a webcam. It will have to be installed in a way that OpenCV can access it as a camera.
@mariorodrigues1888
@mariorodrigues1888 3 жыл бұрын
@@ClaytonDarwin yeah, i understood due to the way how the code gets the image, i already have something working but not at 100% i would need some extra help on that
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Okay. Good that you have it partially working. I'm not able to investigate it at the moment.
@mariorodrigues1888
@mariorodrigues1888 2 жыл бұрын
@@ClaytonDarwin do you think with would be reliable to aply this kind of system to a company ? Controlling measurements with it
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Reliability is based on calibration and testing. Lots of testing. But I would certainly have no issues with using this setup as a base for an industrial application.
@haikalhakim
@haikalhakim 9 ай бұрын
how to calibrate the distortions? it looks your camera have a minimum distortions
@ClaytonDarwin
@ClaytonDarwin 9 ай бұрын
The calibration procedure shown remove the distortion.
@haikalhakim
@haikalhakim 9 ай бұрын
Ah thank you! 😂 i not aware
@haikalhakim
@haikalhakim 8 ай бұрын
@@ClaytonDarwin did you use a telecentric lens for this project?
@ClaytonDarwin
@ClaytonDarwin 8 ай бұрын
@@haikalhakim I don't think so.
@beetb246_aniruddhashinde5
@beetb246_aniruddhashinde5 Жыл бұрын
this is just fantastic, just wanted to know how can i use this on two cameras simultaneously
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
You should be able to run 2 instances. You'll have to explicitly identify the cameras.
@tahafarshbaf
@tahafarshbaf 2 ай бұрын
thanks for sharing
@ehsanullahahmady5962
@ehsanullahahmady5962 3 жыл бұрын
Good job. I want to change your code to make an alarm system. for example, if the size is smaller or bigger of x start alarm. could you please let me know how should I do it? Thank you so much.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
You will have to add object recognition to prevent false alarms, and then insert the alarm routine after the measurement is calculated.
@Krishna-NV
@Krishna-NV Жыл бұрын
what should i do to store the dimensions obtained in auto mode into an excel sheet?
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
The easiest thing would be to write data to a .csv file. Comma separated values can be read by any spreadsheet software.
@keis9558
@keis9558 Жыл бұрын
hello Sir, i want to know what methods do you use in the measurement process?
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
Please see the code.
@DrMoeVEVO
@DrMoeVEVO 3 жыл бұрын
Great job, I immediately subscribed, one question, how could i automate measurement and save it in a excel file to do computations consequently?! Thank you sir
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
In the main loop, about the same place where it writes the values to the frame, you could also write the values into a database or append to CSV file (imports into excel). There are other options, and you may also want to have something you click, otherwise you will have all the stray measurements going into your data. This was really just a template that you could use to make another application. If you want to automate, you will have to do a lot of filtering to get just the data you want.
@DrMoeVEVO
@DrMoeVEVO 3 жыл бұрын
@@ClaytonDarwin Thank you so much for the reply, I'll be trying to measure inhibition of bacteria in a culture medium representing a no growth halo, kudos to you, so this video and your project helps me a lot, I can't thank you enough sir, God bless you, peace and love from Iran
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
One very nice thing about OpenCV is that it has a relatively easy way to train for object recognition. So, you always have the option of adding image recognition into the application. Or maybe more simply shape recognition. This might help you pick your targets automatically. It may be more programming that you are able to do if you are a microbiologist, but if you are in a university or research environment, there is probably a programmer that could help you.
@DrMoeVEVO
@DrMoeVEVO 3 жыл бұрын
@@ClaytonDarwin indeed sir I am grateful for your advice, I am new to the AI field and I appreciate your work and you sharing your knowledge, God bless you and your family🙏
@tumininuadebambo
@tumininuadebambo 2 жыл бұрын
@Lonesome Herd how did your writing to CSV go, can you share? Thanks
@nurulazizah260
@nurulazizah260 3 жыл бұрын
when I measure the camera out of focus, how do I make the camera focus? I use a camera with a resolution of 720p
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I can't answer that. The software is not making the camera out of focus.
@riubotin
@riubotin 2 жыл бұрын
Please Help Me Sir! I just want ask, if I have several object with different size & weight. can I convert the size of bounding box to weight? for example : 12.4 Cm x 5.9 Cm = 1KG. or something like this. " if width 12cm to 13cm and height 5cm to 6cm, print (1KG).. Thanks.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
If a 2D area has a direct relationship to weight for the specific objects that you are measuring, then yes. However, this is not the case for random objects.
@michaelandersen1161
@michaelandersen1161 3 жыл бұрын
What version/ distro of Linux Are you using?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Latest version of Lubuntu, but any Debian derivative works. I'm using the default Ubuntu install of OpenCV from the time the vid was made.
@haziqridzuan3678
@haziqridzuan3678 3 жыл бұрын
Hello sir, do you also put a list of components that you use in this project into the zip file?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
USB camera, desktop PC, ruler.
@matthewlansdaal7627
@matthewlansdaal7627 2 жыл бұрын
would using a single camera like this and something to measure the distance such as a IR distance sensor be able to calulate 3d dimentions of an object such as a mail parcel? My plan is at a larger scale, having the camera approx 1m away from the base. I am unsure if the maths will still work when the distance from camera changes by large amounts.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Yeah, for 3D you will want 2 cameras, and some type of object recognition. You could use two of this setup, or or one of something like the triangulation video. From either, you can get the dimensions you need.
@matthewlansdaal7627
@matthewlansdaal7627 2 жыл бұрын
@@ClaytonDarwin so knowing the distance from the camera will still not provide an accurate measurement? i will need 2 cameras to achieve this?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
If you know the distance to the table and the distance to the top of the package, then you have the height. If you compensate the 2D area to be accurate at the top of the package, then you have area. Area times height is volume for regular shapes. It would take some adjustments to be able to get the top area for different heights. So, I guess you could do it with one camera and a range finder, but it may be easier with 2 cameras.
@malaikakorgaonker677
@malaikakorgaonker677 3 жыл бұрын
Awesome video.. Would like to know how I could use two cameras to get real time three dimensions of an object using opencv
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
👍 OpenCV has a distance mapping method included.
@ishtiakarafat5715
@ishtiakarafat5715 Жыл бұрын
is it possible to deplly on web server ?
@ClaytonDarwin
@ClaytonDarwin Жыл бұрын
Sure, but I'm not sure how you would handle calibration and video.
@matthewlansdaal7627
@matthewlansdaal7627 2 жыл бұрын
I have made a setup using a raspberry pi 3b+ and using your code. my issue is the camera quality while running your code is too low for anything to be measured. when turning on the camera by itself the quality is fine. is this due to the processing speed of the pi? and how do i fix it?
@matthewlansdaal7627
@matthewlansdaal7627 2 жыл бұрын
I am also getting this error, im not very adept in python so was wondering if you knew what it was or how to fix it? CAMERA: [0, 1280, 1024, 1310720, 30] key: [97, 'a'] Traceback (most recent call last): File "camruler.py", line 504, in x1c,y1c = conv(x1-(cx),y1-(cy)) File "camruler.py", line 135, in conv scale = cal[baseround(d,pixel_base)] KeyError: 820
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
I think a raspberry pi will have a hard time with the real time frame rate along with the image manipulation required for measuring and display. However, I haven't tried it on a pi, so I'm not really sure.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
I'll have a look at the code in the morning. But basically the dictionary doesn't have the item being indexed.
@kenzymatrix
@kenzymatrix 3 жыл бұрын
hey clayton, i have a question, can it detect local image instead of real time? if so, how? thanks in advance
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Sure. You can modify the script to not loop, but instead modify one frame and stop. Just use the OpenCV-Python function to open a file instead of starting the camera. But you will have to go through the same calibration process for the camera you use. Everything depends on the camera setup and calibration.
@kenzymatrix
@kenzymatrix 3 жыл бұрын
@@ClaytonDarwin cool, thanks, oh also can it somehow output the detected width and height to terminal?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Yes, just the same as I print other values.
@wetstreets
@wetstreets 2 жыл бұрын
Have you tried changing the orientation of an object to get the actual length. Like in case of diode.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Not really. I did this video because so many people were asking about measuring after watching some of my other videos. I haven't done anything with it since. There are many unexplored options.
@wetstreets
@wetstreets 2 жыл бұрын
@@ClaytonDarwin Thank you for your reply. I will try it myself and if successful, would share the results with you. :)
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
👍
@mohamedfadl789
@mohamedfadl789 3 жыл бұрын
Love your work just one question how do I make the code run on a video that I choose ?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
You have to change the code. Instead of opening a camera you open a file.
@mohamedfadl789
@mohamedfadl789 3 жыл бұрын
@@ClaytonDarwin
@mohamedfadl789
@mohamedfadl789 3 жыл бұрын
@@ClaytonDarwin yeah could you help me with that I'm sort of new to opencv again thanks :D
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Most OpenCV Python tutorials start with reading a video file. I'm not sure I'll have time to look at this anytime soon.
@mohamedfadl789
@mohamedfadl789 3 жыл бұрын
@@ClaytonDarwin yeah I figured as well thanks though
@yusufismailalrazaz6781
@yusufismailalrazaz6781 3 жыл бұрын
Thanks sir, thats great 👍
@channel-gc8vz
@channel-gc8vz 3 жыл бұрын
Can you to measurement color and detector. Function have caribration color. Can you help me?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
OpenCV has built-in functions for color detection. There are many online tutorials for this.
@Adii..740
@Adii..740 2 жыл бұрын
Hey now what should I do when I Have to save the data in memory
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Add some code to save it.
@krisyadav6343
@krisyadav6343 3 жыл бұрын
Hello sir, How to measure stuffs with YOLO or SSD object detection algorithms?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
OpenCV has several object detection methods you could add into the mail loop.
@shivansgupta2415
@shivansgupta2415 3 жыл бұрын
hi, I need help to store the area of the objects captured what changes should I do in the code anyone please help??
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Just write the value to file somewhere in the display loop.
@thesoul2086
@thesoul2086 3 жыл бұрын
Sir which camera you are using here?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Any USB camera should work.
@thesoul2086
@thesoul2086 3 жыл бұрын
@@ClaytonDarwin i liked this pixel quality. That's why iam asking sir.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I'll check and see what it was.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
This one: kzfaq.info/get/bejne/p8xdg66iq87bfZs.html
@parthvekaria984
@parthvekaria984 3 жыл бұрын
In this there is a buffer method, I can't understand it its part in the code. Can you help me please !
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
The script frame_capture.py is a general module that I use for many different application. It works in a separate thread and captures camera frames as they happen. The frames are put into a buffer (holding area) and stored until the main loop can use them. The modules allows the camera to be managed outside the main loop, and prevent frames that are generated by the camera while the main loop is working from being overwritten/lost. In most cases, cameras only have a one-frame buffer. They read a frame and replace the one in the internal buffer, so it you don't read it in time, you lose it.
@parthvekaria984
@parthvekaria984 3 жыл бұрын
@@ClaytonDarwin thank you
@tumininuadebambo
@tumininuadebambo 2 жыл бұрын
Hi Clayton. I wrote a script for a non-contact animal measurement. Is it possible your program is fitted for Animal recognition and measurement thereafter write measurement to a csv file? I'm know yolov3 does recognition but I'm not sure of measurement. Kindly respond. Thank you. N.B my device is built on raspberrypi 4 with python3.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Hi Tumininu. You can definitely take my script and adapt it. OpenCV can easily handle movement detection and object recognition, and it is straightforward to write the data to a csv file with Python. However there may be some physical problems to overcome. The script I wrote uses a single camera, and this requires that you know the distance from the target to the camera in order to determine the measurement. If you don't know the distance to the target, you will have to have a second camera and use triangulation (like my other video) to get the distance. You can then estimate size. Another problem (maybe) will be the raspi 4. It may not be able to process images fast enough to give you the frame rate you desire. The older raspis were very slow, but I haven't tried it with a new raspi 4. Maybe they are fast enough now.
@tumininuadebambo
@tumininuadebambo 2 жыл бұрын
Thank you Clayton. I installed the OpenCv on my Raaspberry pi 4. It seems its to workon sbb_cv virtual memory. I copied your script from your site into my /home/pi/youtube-projects/OpenCV/camruler folder. i tried running 'python3 camruler.py 0'. it gave error on Line 12 in : No module named 'cv2'. kindly make suggestion. My setup uses 2 USB webcamera with known distance from the object (animal). I forgot to tell you I am a novice with programming. I just have a vision of this project and I am learning on the job.
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
@@tumininuadebambo raspberrypi-guide.github.io/programming/install-opencv
@tumininuadebambo
@tumininuadebambo 2 жыл бұрын
@@ClaytonDarwin Thanks i ll go through this.
@tumininuadebambo
@tumininuadebambo 2 жыл бұрын
Hi Clayton. Thank for your usual asistance. I got it working. The frame is so large. How can i minimise it. The video seems i am only working at a corner of my whole view. I have tried changing several figures: width, height.... on the camruler.py. Kindly help again. ps dont get tired. cheers Can you also help withh the line to extract the measurement to a CSV file. Thanks
@discoveryenglish
@discoveryenglish 2 жыл бұрын
We can make lengths and widths. So how can we make weights (kilograms)?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
With a scale? Unless you know some way to estimate weight from 2D measurements.
@discoveryenglish
@discoveryenglish 2 жыл бұрын
@@ClaytonDarwin Let's say we know the weights of some objects. How do we write it into the program? Do you know what the code is?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Add a look-up table in the same place the area is calculated and added to the frame.
@discoveryenglish
@discoveryenglish 2 жыл бұрын
@@ClaytonDarwin Thanks. Could you please write the code?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
I generally don't do other people's work without competition.
@user-wd5wz4ev9m
@user-wd5wz4ev9m 2 жыл бұрын
Do you have C++ code too?
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
Nope. But it should translate easily.
@ClashRoyalePlayer420
@ClashRoyalePlayer420 3 жыл бұрын
Hi Can you make a video on all the methods used for measurement of items using open cv?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Probably don't have time to do that.
@ClashRoyalePlayer420
@ClashRoyalePlayer420 3 жыл бұрын
@@ClaytonDarwin ok
@omoklamok
@omoklamok 7 ай бұрын
hi i follow your videos and it work perfectly but i have question
@user-uc2gc5es1p
@user-uc2gc5es1p 2 жыл бұрын
سلام استاد لطفا درمورد مختصات وعملیات در روی حرکت اشیا که دریک ریل نواری که دوربین فرم به فرم را ثبت میکند را اموزش دهید لطفا
@ClaytonDarwin
@ClaytonDarwin 2 жыл бұрын
I haven't been able to get your message translated yet.
@parthvekaria984
@parthvekaria984 3 жыл бұрын
Can we make it work for multi camera input.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I think so, but I don't have time for it right now. Combine the triangulation video with this one.
@flobartsch8902
@flobartsch8902 3 жыл бұрын
I am working on it currently. Do you have a solution already?
@YazeedAlkosai
@YazeedAlkosai 3 жыл бұрын
Great vedio, how I could measure the surface of the 3D features
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Because you don't know the distance to the target, 3D measurements typically requires 2 cameras and triangulation.
@nikhilrishi2922
@nikhilrishi2922 3 жыл бұрын
Can we calculate volume of object?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
With this setup you only have two dimensions, so area only.
@nikhilrishi2922
@nikhilrishi2922 3 жыл бұрын
@@ClaytonDarwin Thanks for your reply. Does using a stereo camera help calculating volume?
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
Yes.
@nikhilrishi2922
@nikhilrishi2922 3 жыл бұрын
@@ClaytonDarwin Any suggestions which one works the best, in case you ever tried it.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
I have a video where I do some work with two cameras and triangulation to determine distance. However, I haven't tried any off-the-shelf 3D software or cameras.
@DrMoeVEVO
@DrMoeVEVO 3 жыл бұрын
BTW i dog those coins, cool collection👌🏻
@suphasud
@suphasud Жыл бұрын
Wowwwwwwwwwww
@eulamieraz4383
@eulamieraz4383 3 жыл бұрын
Hi, I am currently doing this kind of project, but I really don't know how can I start my codes in Python. I already saw your codes but I can't cope up since I'm not familiar with this yet. Can you help me with this, Sir?
@eulamieraz4383
@eulamieraz4383 3 жыл бұрын
And what kind of microcontroller did you used? Thank you, Sir, in advanced.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
This video does not use a microcontroller.
@ClaytonDarwin
@ClaytonDarwin 3 жыл бұрын
To run this code you will have to install Python and Python-OpenCV. Then it should run using a standard web camera over USB.
@eulamieraz4383
@eulamieraz4383 3 жыл бұрын
@@ClaytonDarwin I already have it, Sir. Sir, can you explain your codes that you used in this video for the beginner like me? I mean, do you have tutorials video on how you write those codes?
@eulamieraz4383
@eulamieraz4383 3 жыл бұрын
@@ClaytonDarwin If I will make a prototype on auto-measuring, what microcontroller you can suggest?
Happy birthday to you by Tsuriki Show
00:12
Tsuriki Show
Рет қаралды 12 МЛН
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 13 МЛН
The Giant sleep in the town 👹🛏️🏡
00:24
Construction Site
Рет қаралды 21 МЛН
REAL TIME OBJECT MEASUREMENT | OpenCV Python (2020)
53:25
Murtaza's Workshop - Robotics and AI
Рет қаралды 246 М.
Calibrate a Camera In Under 5 Minutes (2020)
10:50
The Drone Dojo
Рет қаралды 12 М.
Object Tracking with Opencv and Python
30:03
Pysource
Рет қаралды 606 М.
I run untested, viewer-submitted code on my 500-LED christmas tree.
45:17
The most important Python script I ever wrote
19:58
John Watson Rooney
Рет қаралды 188 М.
I tried to make a Valorant AI using computer vision
19:23
River's Educational Channel
Рет қаралды 1,5 МЛН
Counting Coin in an Image using OpenCV Python.
13:47
Datum Learning
Рет қаралды 7 М.
Happy birthday to you by Tsuriki Show
00:12
Tsuriki Show
Рет қаралды 12 МЛН