Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • mhoeschle/baslerpypylontools
1 result
Show changes
Commits on Source (7)
Scripts
Include
Lib
\ No newline at end of file
Lib
vscode/
.venv/
.vscode/
\ No newline at end of file
......@@ -8,8 +8,13 @@ import time
# Variable:
#
camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
camera = pylon.InstantCamera()
COLCAMNAMES = {
'22320672': 'acA2000-165uc',
'24531290': 'acA1920-40uc',
'24531319': 'acA1920-40uc',
}
"""
......@@ -20,45 +25,63 @@ Function
# list all the connected cameras at the system:
#
def listcam():
"""
schows all connected Basler cameras
"""
# Generates a list of the cameras connected to our computer, like what we see with the PylonViewer program
# Generates a list of the cameras connected to our computer, like what we see with the PylonViewer program
tl_factory = pylon.TlFactory.GetInstance()
#print(tl_factory)
tl_factory = pylon.TlFactory.GetInstance()
# print(tl_factory)
devices = tl_factory.EnumerateDevices()
#print(devices)
# print(devices)
allcam = []
for device in devices:
print("Device Input (Camera Type & (Serialnumber)):")
print("-", device.GetFriendlyName(), "\n") # Model name + Serial number
# Model name + Serial number
print("-", device.GetFriendlyName(), "\n")
#print("-", device.GetModelName())
#print("-", device.GetSerialNumber(), "\n")
allcam.append(device.GetFriendlyName())
return allcam
# foundcams retrun a list with all connected cameras.
#foundcams = listcam()
# for cam in foundcams:
#print(f'found cam: {cam}')
#
# open camara device
#
def opencam():
def opencam():
"""
opens interface to camera
Creates an instant camera object with the camera device found first.
"""
# Create an instant camera object with the camera device found first.
## camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
#
# camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
# open camera, crate a device!
#
print("openDevice:", "\n")
return camera.Open()
#opencam()
# opencam()
#
# close camera interface
#
def closecam():
"""
close interface to camera
......@@ -67,12 +90,13 @@ def closecam():
## camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
print("closeDevice:", "\n")
return camera.Close()
#closecam()
# closecam()
#
# read parameters in camara
#
def readcam():
"""
read out current settings from camera via interface
......@@ -87,12 +111,12 @@ def readcam():
# Read Trigger Delay value in Camera:
print("Delay in (microseconds):")
# TriggerDelay value
# TriggerDelay value
print(camera.TriggerDelay.Value, "\n")
# Exposure parameter
oldexposure = camera.ExposureTime.GetValue()
print(f'exposure: {oldexposure}',"\n")
print(f'exposure: {oldexposure}', "\n")
oldfps = camera.AcquisitionFrameRate.GetValue()
print(f'fps: {oldfps}')
......@@ -101,7 +125,7 @@ def readcam():
print("Camera gamma value: ")
print(camera.Gamma.GetValue(), "\n")
closecam()
# closecam()
#
......@@ -124,12 +148,16 @@ def gaincam():
# Gain value
print(camera.Gain.Value, "\n")
closecam()
#cameragain()
# gaincam()
#
# Funktion for changing the exposure time in microseconds (e.g. 1000 ms):
#
def exosurecam():
def exposurecam():
"""
changes the exposure time in microseconds (ms)
"""
......@@ -148,12 +176,15 @@ def exosurecam():
print(camera.ExposureTime.GetValue(), "\n")
closecam()
#exosurecam()
# exposurecam()
#
# Funktion for changing the aquisation frame rate in fps (e.g. 30 fps):
#
def aquisationfps():
"""
enable / dissable auto or manual fps and
......@@ -162,7 +193,7 @@ def aquisationfps():
opencam()
status = camera.AcquisitionFrameRateEnable.GetValue()
print(f'fps enable? {status}')
statusenable = str(input("Do you want to change fps, (y/n)? "))
if statusenable.lower() == 'y':
......@@ -172,16 +203,16 @@ def aquisationfps():
newfps = input("Choose your fps: ")
camera.AcquisitionFrameRate.SetValue(float(newfps))
print(f"New fps is: {newfps}",'\n')
print(f"New fps is: {newfps}", '\n')
else:
print("disabled Aquisation Frame rate!")
camera.AcquisitionFrameRateEnable.SetValue(False)
closecam()
#aquisationfps()
# aquisationfps()
#
......@@ -195,7 +226,8 @@ def triggerdelaycam():
opencam()
print(f'trigger delay is: {camera.TriggerDelay.GetValue()}')
newtriggerdelay = input("Please enter new trigger delay in (microseconds): ")
newtriggerdelay = input(
"Please enter new trigger delay in (microseconds): ")
camera.TriggerDelay.SetValue(float(newtriggerdelay))
......@@ -203,8 +235,7 @@ def triggerdelaycam():
closecam()
#triggerdelaycam()
# triggerdelaycam()
# How to show the images ?
......@@ -225,10 +256,16 @@ def freeruncam():
break
print(f'Acquired {i} frames in {time.time()-t0:.0f} seconds')
# freeruncam()
# ---> ongoing, not yet in usage.
if __name__ == '__main__':
listcam()
foundcams = listcam()
for cam in foundcams:
print(f'found cam: {cam}')
readcam()
# BaslerPypylonTools
### Hi there 👋, my name is Markus
hello world1231313123
5 basic commands
#### BaslerChangeParameters
git pull (pulls new changes )
git add * adds all changes in the folder to the commit
git add filename - adds only one file to commit
git commit -m "message" creates a commit with changes
git push - pushes commits to the repository
I made this project just for fun, it allows you to read out and change any settings in the basler cameras.
This should be helpful if you are using more than one camera and you want to make changes to several ones at once, same parameter and value.
## Getting started
##### Execute Script
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Execute the scipt via cmd. BaslerChangeParameters.py
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
##### Next steps
## Add your files
Connect to several computers via network and get acces to pypylone to change the settings in those cameras too.
unsing netconnect.py.
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.tuebingen.mpg.de/mhoeschle/baslerpypylontools.git
git branch -M main
git push -uf origin main
```
Skills: python, cmd,
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.tuebingen.mpg.de/mhoeschle/baslerpypylontools/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
- 🔭 I’m currently working on this page.
\ No newline at end of file
start cmd.exe /k "python -m venv . "
\ No newline at end of file
# create virtual enviroment in Visual Studio code
start cmd.exe /k "python -m venv .venv "
\ No newline at end of file
#
# Original solution via StackOverflow:
# http://stackoverflow.com/questions/35802939/install-only-available-packages-using-conda-install-yes-file-requirements-t
#
#
# Install via `conda` directly.
# This will fail to install all
# dependencies. If one fails,
# all dependencies will fail to install.
#
conda create -n 'embryolearning'
source activate embryolearning
conda install --yes --file requirements.txt
#pip install --yes --file requirements.txt
#
# To go around issue above, one can
# iterate over all lines in the
# requirements.txt file.
#
while read requirement; do conda install --yes $requirement; done < requirements.txt
pip install opencv-python
pip install albumentations
import smbclient
from smbprotocol.exceptions import LogonFailure, SMBOSError
import getpass
from smbclient.path import isdir, exists
import BaslerChangeParameter
'''
Code connect to 2 DVR's and make temporary changes for the Basler camera, only for calibration mode
Steps:
Read out existing cameras values
change values
recording via external Software
stop calibration recording
close connection
'''
def connectnet():
"""
Enter username and password to connect to server
"""
# Ask for login name of the user
user = input("Please, enter username: ")
# username = str('mpi\\' + user)
username = str(user)
print(f'Hello {user}')
# The getpass module for inserting password
password = getpass.getpass("Please enter your password: ")
# Get server name to connect to: for e.g. "ps-access.is.localnet"
# server = input("Please enter the servername or IP to connect to: ")
# Setup Test computer and connect basler cam to it, to test connection and execution
servers = {
'10.34.22.41': '191031-01handU',
# '10.34.25.94': 'DESKTOP-8KL64PU',
# '10.34.22.31': 'DVR12',
# '10.34.22.32': 'DVR13',
# '10.34.22.33': 'DVR14',
# '10.34.22.34': 'DVR15'
}
# Optional - register the credentials with a server (overrides ClientConfig for that server)
# smbclient.register_session("server", username="user", password="pass")
for server in servers:
# For testing - D:\ is external HHD
# If no Harddrive is needed to run the code this lines shouldn't be activated!
#LOCALDIRECTORIES = [f"\\\\{server}\\c\\"]
# ['C:\\', 'U:\\', 'V:\\', 'W:\\', 'X:\\', 'Y:\\', 'Z:\\'] for the DVR's
try:
# Connect to server:
smbclient.register_session(server, username, password)
print(f'Connected!! to: {server}')
# Test on DVR 1 Hand scanner
# smbclient.mkdir(
# f"\\\\{server}\\c$\\Users\\3dmd\\Desktop\\test12345")
# Start script to for camera manipulation with pypylone:
# List current current cameras
BaslerChangeParameter.listcam()
# connect to the following cameras
# BaslerChangeParameter.opencam()
#directories = smbclient.listdir(f"\\\\{server}\\c\\")
# print(directories)
# smbclient.(f"\\\\{server}\\c\\")
# debug
# break
except LogonFailure as e:
print(f"Login error: \n\t {e}")
except SMBOSError as e:
print(f"OS error: \n\t {e}")
print(f'close server: {server}')
if __name__ == "__main__":
connectnet()