簡體   English   中英

Python 收割機圖像采集 GigeCam

[英]Python Harvesters Image Acquisition GigeCam

我嘗試從我的 gige 相機獲取圖像。 在相機自己的軟件中它工作得很好,但是當我用收割機做它時,我的圖像有一個奇怪的網格,我不知道它為什么在那里以及如何刪除它。 我需要這個用於立體視覺項目。 任何想法? 不要介意我用更高的 expo 嘗試過的亮度,它沒有改變任何東西。 :D

在此處輸入圖像描述

import genicam.genapi as ge
import cv2
from harvesters.core import Harvester
import matplotlib.pyplot as plt
import numpy as np

# Create a Harvester object:
h = Harvester()

# Load a GenTL Producer; you can load many more if you want to:
h.add_file("C:/Program Files\MATRIX VISION/mvIMPACT             Acquire/bin/x64/mvGenTLProducer.cti")
# Enumerate the available devices that GenTL Producers can handle:
h.update()

# Select a target device and create an ImageAcquire object that
# controls the device:
ia = h.create(0)
ia2 = h.create(1)

# Configure the target device; it looks very small but this is just
# for demonstration:
ia.remote_device.node_map.Width.value = 1456
ia.remote_device.node_map.Height.value = 1088
# ia.remote_device.node_map.PixelFormat.symbolics
ia.remote_device.node_map.PixelFormat.value = 'BayerRG8'

ia2.remote_device.node_map.Width.value = 1456
ia2.remote_device.node_map.Height.value = 1088
# ia2.remote_device.node_map.PixelFormat.symbolics
ia2.remote_device.node_map.PixelFormat.value = 'BayerRG8'

ia.remote_device.node_map.ChunkSelector.value = 'ExposureTime'
ia.remote_device.node_map.ExposureTime.set_value(100000.0)

ia2.remote_device.node_map.ChunkSelector.value = 'ExposureTime'
ia2.remote_device.node_map.ExposureTime.set_value(100000.0)

# Allow the ImageAcquire object to start image acquisition:
ia.start()
ia2.start()
# We are going to fetch a buffer filled up with an image:
# Note that you'll have to queue the buffer back to the
# ImageAcquire object once you consumed the buffer; the
# with statement takes care of it on behalf of you:
while True:
    with ia.fetch() as buffer:
    component = buffer.payload.components[0]
    _2d = component.data.reshape(1088, 1456)
    img = _2d
    img = cv2.resize(img,(640,480))
    cv2.imshow('right',img)
    cv2.imwrite('test_left.png',img)
    cv2.waitKey(10)
with ia2.fetch() as buffer:
    component = buffer.payload.components[0]
    _2d = component.data.reshape(component.height, component.width)
    img2 = _2d
    img2 = cv2.resize(img2, (640, 480))
    cv2.imshow('left', img2)
    cv2.imwrite('test_right.png',img2)
    cv2.waitKey(10)

ia.stop()
ia2.stop()
ia.destroy()
ia2.destroy()
h.reset()

我只需要使用 cvtColor 將它轉換為灰色或 RGB,然后它就可以工作了。 不管怎么說,還是要謝謝你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM