Skip to content

Commit

Permalink
Merge pull request #71 from Junang-Wang/GrisNuAge-patch-4-1
Browse files Browse the repository at this point in the history
Add files via upload
  • Loading branch information
Junang-Wang authored Apr 10, 2024
2 parents 639c0b3 + cb15afe commit 3402407
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions CV/Codes/balser_setting.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from pypylon import pylon
import cv2

# Create camera object
camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())

# Start grabbing (video) with minimal delay
camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly)
camera.ExposureAuto.SetValue = 'Off'
camera.ExposureTimeRaw.SetValue(30000)

# Set image format converter
converter = pylon.ImageFormatConverter()
converter.OutputPixelFormat = pylon.PixelType_BGR8packed
converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned

# # Set camera parameters (adjust as needed)
# camera.Width.SetValue = 1000
# camera.Height.SetValue = 500
# camera.OffsetX.Value = 0
# camera.OffsetY.Value = 0

# Continuously grab and display frames
while camera.IsGrabbing():
# Grab the latest image
grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)

if grabResult.GrabSucceeded():
# Convert image to OpenCV format
image = converter.Convert(grabResult)
frame = image.GetArray()

# Display the frame
cv2.imshow('Basler Camera Stream', frame)

# Exit on 'q' press
if cv2.waitKey(1) & 0xFF == ord('q'):
break

# Release grab result
grabResult.Release()

# Stop grabbing and release resources
camera.StopGrabbing()
cv2.destroyAllWindows()

0 comments on commit 3402407

Please sign in to comment.