Giter Site home page Giter Site logo

Comments (7)

AlexShkarin avatar AlexShkarin commented on August 15, 2024 1

OK, in this case the only solution I can see is to try to override the value if PayloadSize. For that you'll need to edit pylablib/devices/IMAQdx/IMAQdx.py file line 433 and replace it with, e.g., size_bytes=self.cav["Height"]*self.cav["Width"]*4. This will break the functionality for other pixel formats (which don't have 4 bytes per pixel), but has a chance of fixing your issue.

from pylablib.

AlexShkarin avatar AlexShkarin commented on August 15, 2024

Yeah, it looks like the frame size is calculated incorrectly. This is a bit strange, though, since the code uses the IMAQdx-provided PayloadSize attribute which, one would hope, should be correct.

To start, it would be interesting to check all other camera attributes. Could you get their values by running atts=device.cav[""] and send them here? In addition it would be good to compare these with the values you get in the Acquisition Attributes tab in NI MAX, and check the possible values of Video Mode and Pixel Format parameters there.

from pylablib.

bhathawayML avatar bhathawayML commented on August 15, 2024

Hello!

This is my output (and I confirmed these are the same values I see in NI MAX):

atts = Dictionary(
'AcquisitionAttributes/Bayer/Algorithm': Bilinear
'AcquisitionAttributes/Bayer/GainB': 1.0
'AcquisitionAttributes/Bayer/GainG': 1.0
'AcquisitionAttributes/Bayer/GainR': 1.0
'AcquisitionAttributes/Bayer/Pattern': Use hardware value
'AcquisitionAttributes/BitsPerPixel': Use hardware value
'AcquisitionAttributes/HardwareMaximumQueuedBufferCount': 1000
'AcquisitionAttributes/HardwareRequeueBufferListThreshold': 50.0
'AcquisitionAttributes/Height': 1520
'AcquisitionAttributes/ImageDecoderCopyMode': Auto
'AcquisitionAttributes/OutputImageType': Auto
'AcquisitionAttributes/OverwriteMode': Get Newest
'AcquisitionAttributes/PayloadSize': 8755200
'AcquisitionAttributes/PixelFormat': BGRA 8 Packed
'AcquisitionAttributes/ReceiveTimestampMode': None
'AcquisitionAttributes/ShiftPixelBits': False
'AcquisitionAttributes/SwapPixelBytes': False
'AcquisitionAttributes/Timeout': 5000
'AcquisitionAttributes/VerticalMirror': False
'AcquisitionAttributes/VideoMode': 1920x1520 MJPG 30.00fps
'AcquisitionAttributes/Width': 1920
'CameraAttributes/BacklightCompensation/Mode': Manual
'CameraAttributes/BacklightCompensation/Value': True
'CameraAttributes/Brightness/Mode': Manual
'CameraAttributes/Brightness/Value': 0
'CameraAttributes/Contrast/Mode': Manual
'CameraAttributes/Contrast/Value': 0.0
'CameraAttributes/Exposure/Mode': Manual
'CameraAttributes/Exposure/Value': 0.125
'CameraAttributes/Gamma/Mode': Manual
'CameraAttributes/Gamma/Value': 1.0
'CameraAttributes/Hue/Mode': Manual
'CameraAttributes/Hue/Value': 0.0
'CameraAttributes/Saturation/Mode': Manual
'CameraAttributes/Saturation/Value': 64
'CameraAttributes/Sharpness/Mode': Manual
'CameraAttributes/Sharpness/Value': 2
'CameraAttributes/WhiteBalance/Mode': Manual
'CameraAttributes/WhiteBalance/Value': 4600
'CameraInformation/BaseAddress': 0
'CameraInformation/BusType': DirectShow
'CameraInformation/ModelName':
'CameraInformation/SerialNumberHigh': 2531778714
'CameraInformation/SerialNumberLow': 2530362052
'CameraInformation/VendorName': MD1200A
'StatusInformation/AcqInProgress': True
'StatusInformation/LastBufferCount': 131
'StatusInformation/LastBufferNumber': 130
'StatusInformation/LostBufferCount': 0
'Height': 1520
'PayloadSize': 8755200
'PixelFormat': BGRA 8 Packed
'Width': 1920)

from pylablib.

AlexShkarin avatar AlexShkarin commented on August 15, 2024

Could you examine other possible pixel formats by checking the value of ``device.ca["PixelFormat"].values"? It could be that some other format (e.g., not involving the alpha-channel or a monochrome one) would work better for you.

from pylablib.

bhathawayML avatar bhathawayML commented on August 15, 2024

Only ['BGRA 8 Packed'] is an available option.

from pylablib.

bhathawayML avatar bhathawayML commented on August 15, 2024

That fixed it! Thank you so much. I added the following lines after the pixel_format definition to hopefully avoid problems with other formats:

if "BGRA" in pixel_format or "RGBA" in pixel_format:
    size_bytes = self.cav["Height"] * self.cav["Width"] * 4
else:
    size_bytes = self.cav["PayloadSize"]

from pylablib.

AlexShkarin avatar AlexShkarin commented on August 15, 2024

Glad that worked! I'll add something similar to the next version, either by trying to figure out the number of bytes based on the pixel format, or by adding an option to specify it explicitly (for some weird packed formats).

from pylablib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.