Comments (4)
This is how I managed to convert BayerBG8 to RGB and save images using Imageio (since I mostly work with NumPy arrays), maybe this helps you guys:
from pypylon import pylon
import imageio
# create InstantCamera and grab image
camera = pylon.InstantCamera(
pylon.TlFactory.GetInstance().CreateFirstDevice())
grab_result = camera.GrabOne(1000)
# create NumPy array from BayerBG8 grab result
# and save Bayer raw image as grayscale BMP
image_bayer = grab_result.GetArray()
imageio.imsave('image_bayer.bmp', image_bayer)
# create and configure ImageFormatConverter
converter = pylon.ImageFormatConverter()
converter.OutputPixelFormat = pylon.PixelType_RGB8packed
# convert image to RGB, create NumPy array
# and save RGB image as color BMP
converted = converter.Convert(grab_result)
image_rgb = converted.GetArray()
imageio.imsave('image_rgb.bmp', image_rgb)
from pypylon.
ok so I got it to work using cv2
. choose cv2
Bayer type based on your camera pixel format.
mine was PixelType_BayerGR12 so I am using COLOR_BayerGR2BGR.
import numpy as np
import cv2
raw_np = np.fromfile(img_path)
raw_img = np.ndarray((IMAGE_HEIGHT, IMAGE_WIDTH), dtype=np.uint16, buffer=raw_np)
debayered_img = cv2.cvtColor(raw_img, cv2.COLOR_BayerGR2BGR)
Now one thing to note here is. debayered image in my case is a 16 bit image. but pixel values are 12 bit.
so image would look really dark. if you choose to convert it to 16 bit just multiply it by 2**4
from pypylon.
I also have exact same question. I currently use
img_result.GetArray(raw=True).tofile('out_raw_img')
but I am afraid that I have lost all grab result attributes of the image for the images I have saved for quite sometime now. I now want to use image converter on those files but it doesn't work on raw files. 😞
from pypylon.
@derFRUST conversion is fine if you have access to GrabResult
object.
in my case I don't have GrabResult
object available. because I stored raw frame on the disk using img_result.GetArray(raw=True).tofile('out_raw_img')
.
now I want to debayer that raw frame from disk.
from pypylon.
Related Issues (20)
- camera.AcquisitionFrameRate.SetValue() is not accurate HOT 2
- Error: 3774873620 The buffer was incompletely grabbed. HOT 5
- fail when install pypylon on raspberry pi HOT 3
- Setting up PTP with multiple cameras HOT 10
- Grab timed out at random HOT 7
- Pypylon - unable to set Width or Height HOT 2
- I want to read temperatures at different parts of the camera but it is not possible HOT 3
- Triggering the camera with a push button, raspberry Pi and python script HOT 4
- Camera Connection İssue HOT 5
- Read operation failed, 2717909792 HOT 1
- Camera timing out during acquisitions HOT 1
- Application Settings for High Performance HOT 2
- BUG: Segfault in Pylon viewer HOT 4
- BUG: Cannot set exposure time using acA4024-29um HOT 2
- BUG: Memory leakage in pypylon 3.0.1? HOT 9
- Floating sync with audio while 2 Basler daA1920-160uc hardware triggered by arduino HOT 2
- Pyyylon leaving open files (or pipes) after stopping the cameras HOT 4
- Cannot set Gamma value for camera (AccessException) HOT 3
- Asynchronous grabbing from a 2-camera array HOT 5
- Need high FPS but using Result.Array drastically slows down acquisition of data HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pypylon.