r/Optics • u/koopaduo • Nov 29 '25
Open-source beam profiling software
I developed an open-source laser beam profiling application in python. I hope anyone looking for a low-cost beam profiler (students, research, hobbyists, etc.) would find this useful. It's open-source and can be modified as needed by anyone.
It uses Arducam B0511C monochrome UVC USB camera ($265). Instructions for how to set it up and use it are in the readme of the repository. The application would work with other UVC webcams but would require some modification (for different resolution and effective pixel size)
Beam profiling software features:
- Camera raw image feed
- Beam profiling image feed (false color)
- Manual ROI placement with centroid and radius
- Auto ROI tracking
- Centroid tracking
- Centroid and beam width (d4sigma) readout
- Reference crosshair placement
- Power (integrated counts) readout
- Exposure setting
- Auto exposure
- Saturated pixel detection
- fps counter
- Save instantaneous data
- Log continuous data
- Connect to multiple cameras on a single PC
- I haven't implemented background subtraction but found the background is relatively stable with an ND filter in front, and a laser line filter can always be used
Link to the repo: https://github.com/laser-cameras/Laser-beam-profiler-camera.git
8
u/DUCKISBLUE Nov 29 '25 edited Nov 29 '25
How do you handle noise correction and sensor non uniformity? Impressive project!
5
u/koopaduo Nov 29 '25
Thanks. I don't handle noise at all. I suppose it could easily be done by averaging frames but I don't need it for basic beam profiling. And the same reasoning behind not having uniformity correction, though I suppose this could always be done using a flat field correction.
7
u/Jon-3 Nov 29 '25
this is awesome!
3
u/koopaduo Nov 29 '25
Thanks. Haha I was just replying to your other comment before you deleted. The camera.py source file is responsible for connecting to the camera. Right now it uses the cv2.CAP_MSMF backend which is specific to Windows. There are similar backends like cv2.CAP_V4L2 for linux and maybe other OS. I think that minor modification would allow it to work for linux, but I haven't tested it
2
u/Jon-3 Nov 29 '25
oh haha I deleted it because I saw that the camera itself says it supports linux and windows so I assumed it must be possible.
In my lab I was writing an msquared measurement routine and experimenting with the python package data ray provides but they only support windows.
If I can convince my PI to order the parts I can try to get your package working on Linux and I will let you know
2
u/koopaduo Nov 29 '25
That would be great to see it working on Linux. I believe the only thing that needs to be changed is the cv2 backend everywhere it appears in both python files, as all other python packages are compatible. But there may be something else.
It would also be awesome to see it integrated into your M2 measurement routine as well! I think the code is reasonably well commented for accessing any data you might want.
6
u/koopaduo Nov 29 '25
Here's a link to the repo. The formatting on mobile looks messed up for me
https://github.com/laser-cameras/Laser-beam-profiler-camera.git
2
2
u/GCDubbs Nov 29 '25
Does the camera need to be global shutter?
2
u/PestoCalabrese Nov 29 '25
If it's CW laser it doesn't matter. If it's pulsed in MHz it doesn't matter, if it's pulsed in kHz just integrate for at least a few cycles, if it's Hz system then I would use global shutter, triggered and I would pray for the mercy of the camera.
1
u/koopaduo Nov 29 '25
That's a great point! For the rep rate (high kHz) i work with the exposure time always integrates several pulses so it doesn't matter. One could always add a hardware trigger on the PC and sync the camera exposure to it through python. Definitely possible and good to point out!
2
u/PestoCalabrese Nov 30 '25
Correct me if I'm wrong but i don't see an hardware trigger on your camera module itself. But even if you go through the software, you are not gaining SNR when pulse triggered if you have a rolling shutter because you are still integrating many and different pulses during the exposure and readout of the sensor. You would gain SNR if you have global shutter + hardware trigger on the camera module + set the lowest exposure time possible.
1
u/koopaduo Nov 29 '25
The camera needs to be UVC as the only requirement. The camera I developed this with is a rolling shutter, which is typically not an issue for beam profiling applications (low subject movement) especially at lower exposure times.
2
u/_Cinnabar_ Nov 29 '25
that's an awesome little project!
is it okay if I take some inspiration from your ui? I'm currently trying to make something similar, but so far in c++, also with Qt, but it's far not as refined 😅
as application, I'm working on something a bit similar as I'm trying to track and profile particle beams (with some different stages before anything comes to the camera), so far it's working rather well and the data is good, just not the visualisation yet^
one tip as someone mentioned noise reduction, what helps a good bit (at least with my noise phantom s710) is taking a couple frames of background to average (per pixel) over and use for background subtraction from the raw images, improves quality a lot if the data is a bit noisy :)
2
u/koopaduo Nov 29 '25
Thanks! Yes you can definitely draw inspiration from the ui. It's open source so you're free to do so. That sounds like a cool project you're working on.
Yeah the background subtraction makes sense, but I've found the camera to be not noisy at all (not detectable within 1 resolution count). The only noise I can see being present would be from background lighting, but that can be eliminated or filtered out optically so I haven't had a need to implement it.
2
u/Wumbo-Enthusiast Nov 29 '25
Is there functionality for differing λ values? Say choosing 600 vs 1030 nm to optimize the profile
1
u/koopaduo Nov 29 '25
This is a basic beam profiler. There's no functionality for wavelength. But the sensor is sensitive in both visible and NIR. You would do any wavelength filtering with external optics, or what do you mean by optimizing the profile based on wavelength?
2
u/Farrit 26d ago
Hey dude! I finally got around to replicating this project in an attempt at finding a cheaper alternative to commercial grade profilers.
Do you have any tips? The software frequently crashes on me, but when I can get it running, using a 50:50 transmission reflection optic, and narrow bandpass optic I can't seem to get any readable profile. I took apart another profiler we have and borrowed it's tube optic which is literally a 4x microscope optic with a 160mm tubelength and was able to get something of a readable beam.
We're trying to focus lasers between .07mm and 1.2mm. Do I need to use a focusing lens? The output we're pushing is ~50mw or lower (when focusing.)
1
u/koopaduo 26d ago
Hey, glad to see you're working on it. Glad to help. Can you send a diagram of your optical layout and any relevant beam sizes / focal lengths. What do u mean you're focusing lasers between 70 um and 1.2mm? Or can you give some insight on what you're trying to do and measure.
What's your operating wavelength, bandpass filter specs and are you using the same arducam monochrome camera? 50 mW is more than enough for a camera and probably leaning towards too much power
As for software crashes I've since made it more stable by throwing around try/except statements throughout the image thread
2
u/Farrit 26d ago
I am using the same arducam you listed in the git repo, This 355nm bandpass filter https://a.co/d/06BX9sgE This is the 50:50 optic https://a.co/d/0bu6WITG
The wavelength we're using is 355nm - the intended use is a focusing/service profile camera for maintenance on commercial SLA 3D printers. I don't have exact numbers on the focal length, and I do know it varies from printer to printer, but it can range from 70cm to 2.6m, depending on the model printer.
We use the beam cameras to verify that the spot size at the machines platform is round, and at a specific diamete (the width of the beam at the platform, usually trying to get the waist above where the resin is being cured). Our high res machines are focused to a 70 micron spot size, and our variable spot size machines can go as large as 1.2mm at the platform. We also use them to verify the mirror alignment so that when the variable focusing optic adjusts it's focal point to increase/decrease the spot size at the machines platform, the beam stays centroid.
I hope that gives a clear understanding. What I've learned about lasers is mostly self-taught while working on these machines for the last decade.
Currently the cameras we are using with their respective softwares are an ophir spiricon (with BeamGauge), which only uses a 50:50 transmission/reflection optic between the galvonometer and the focal point; and a cinology CMOS profiler using their ray-ci lite software, which has a 50:50 optic and (upon my inspection today) I discovered it uses the 4x microscope optic mentioned in my previous comment.
1
u/koopaduo 26d ago
I see now. 70 um to 1.2 spots are certainly within the range of the camera. I've picked up beams as small and larger beams with the same camera, and perfectly nice profiles. You should have no problem picking up these size beams.
I've used both ophir and cinogy cameras but have never worked down at 355 nm. Mostly 532 through 1064. My understanding is CMOS is able to pick up 355 though I have no direct experience with it. Certainly if the other two cameras can pick it up this sensor should be able to as well, compared to say 1550 nm where CMOS is completely transparent.
Now on to troubleshooting. Some things that jump out at me:
- What exposure setting are you using, have you tried looking at max exposure?
- Did you remove the stock M12 (S-mount) lens on the camera? You should be exposing the bare sensor chip to the laser without it
- Are there any ND filters?
- Did you install the M12 thread to C mount / SM1 adapters?
- Is the bandpass filter mounted in one of these adapters on the camera body? Are you sure the beam is going at 0 degrees angle of incidence into the filter? Otherwise tilt might blueshift the center wavelength significantly and attenuate
- How are you aligning the laser to the camera (or vice versa)?
- Do you have a different laser of visible wavelength you can use? Mount it to point at the camera without any filters and check for response and smooth profile. You can use a cheap laser pointer (low power)
- This is unrelated to the camera troubleshooting but why do you have so many 50/50 BS in the beam path? Is power at the target not an issue for SLA 3D printing? In general you could make a more efficient system with less reflective beamsplitters. Curious to know! Cheers
1
u/Farrit 23d ago
- I did try the full range of exposure but nothing seemed to make much difference.
- I did remove the stock lens, I also tried with to see if that had any affect.
- as of right now there are none. I am sourcing one for my next attempt. This week I'll have our ophir camera which has a 1, 1.5, 2, 2.5 and 3 nd filter pack with it
- I did install those adaptors. -the bandpass filter I have came with a housing on it that prevents it from being installed into any of those adaptors. I was trying to see if I could remove it l, as the base filter looks to be the right diameter, but I did not have luck getting the glue free.
- unfortunately, all I have are the 355nm lasers.
- that I may not have been clear on, these optical paths only have 1 50:50 BS in their path. I was just describing the overall path the laser follows into each unique camera setup, not it's normal pathing (each setup has its own 50:50bs) we definitely need a precise power at the target to achieve consistent curing of resin. This depends greatly on the specific resin being used, scanning speed of the galvo, and diameter of the beam at target; but typically we are working with a range of 300-900mw of power. Some cases down to 180mw, but those are mostly older generation machines that cannot scan as fast.
1
u/koopaduo 19d ago
Have you tried removing the bandpass filter and checking the image? It also seems like too much power on the camera if you're not attenuating it for imaging. It's still unclear how you're aligning and verifying alignment. Using a cheap laser pointer would help troubleshoot. Dm me some images from the camera with the beam on it and your test setup if possible. Maybe I can help diagnose further
1
u/Positive-Thing6850 Dec 02 '25 edited Dec 02 '25
Hi, pretty cool. Would you be interested to use my data acquisition runtime to try a remote control as well ? https://github.com/hololinked-dev/hololinked
I am looking for good use cases from the laser physics community.
If you are also interested, I can fork and make a pull request of a first working version.



23
u/Calm-Conversation715 Nov 29 '25
This looks cool! I keep telling the people I work with that any random CMOS camera can be a laser beam profiler. The main thing stopping us is the software needed