René's URL Explorer Experiment


Title: Unable to change PixelFormat with AccessMode.Full · Issue #178 · alliedvision/VimbaPython · GitHub

Open Graph Title: Unable to change PixelFormat with AccessMode.Full · Issue #178 · alliedvision/VimbaPython

X Title: Unable to change PixelFormat with AccessMode.Full · Issue #178 · alliedvision/VimbaPython

Description: Hello, I am modifying the asynchronous_grab_opencv.py example to set the camera's configuration from an XML file that I have, which contains exposure / color balance configuration that I like. However, when I try to call cam.load_setting...

Open Graph Description: Hello, I am modifying the asynchronous_grab_opencv.py example to set the camera's configuration from an XML file that I have, which contains exposure / color balance configuration that I like. Howe...

X Description: Hello, I am modifying the asynchronous_grab_opencv.py example to set the camera's configuration from an XML file that I have, which contains exposure / color balance configuration that I like. ...

Opengraph URL: https://github.com/alliedvision/VimbaPython/issues/178

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unable to change PixelFormat with AccessMode.Full","articleBody":"Hello,\r\n\r\nI am modifying the asynchronous_grab_opencv.py example to set the camera's configuration from an XML file that I have, which contains exposure / color balance configuration that I like.\r\n\r\nHowever, when I try to call cam.load_settings() I get an exception:\r\n`vmbpy.error.VmbFeatureError: Invalid access while calling 'set()' of Feature 'PixelFormat'. Read access: allowed. Write access: not allowed. `\r\n\r\nI have added a call to set the access mode of the camera to \"Full\", in the get_camera method (it's the only place where the cam object is not in a with context block)\r\n\r\nI have checked that the access mode is still set to Full later when I call load_settings.\r\nI am at a loss as to why this doesn't work, I can change the PixelFormat no problem in VimbaXViewr, that's how I generated this XML file in the first place.\r\n\r\nAny help would be appreciated. Thanks in advance.\r\n\r\nHere is the python script in its entirety:\r\n\r\n```\r\n\"\"\"BSD 2-Clause License\r\n\r\nCopyright (c) 2023, Allied Vision Technologies GmbH\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions are met:\r\n\r\n1. Redistributions of source code must retain the above copyright notice, this\r\n   list of conditions and the following disclaimer.\r\n\r\n2. Redistributions in binary form must reproduce the above copyright notice,\r\n   this list of conditions and the following disclaimer in the documentation\r\n   and/or other materials provided with the distribution.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\r\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\r\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\r\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r\n\"\"\"\r\nimport sys\r\nfrom typing import Optional\r\nfrom queue import Queue\r\n\r\nfrom vmbpy import *\r\n\r\n\r\n# All frames will either be recorded in this format, or transformed to it before being displayed\r\nopencv_display_format = PixelFormat.Bgr8\r\n\r\n\r\ndef print_preamble():\r\n    print('///////////////////////////////////////////////////')\r\n    print('/// VmbPy Asynchronous Grab with OpenCV Example ///')\r\n    print('///////////////////////////////////////////////////\\n')\r\n\r\n\r\ndef print_usage():\r\n    print('Usage:')\r\n    print('    python asynchronous_grab_opencv.py [camera_id]')\r\n    print('    python asynchronous_grab_opencv.py [/h] [-h]')\r\n    print()\r\n    print('Parameters:')\r\n    print('    camera_id   ID of the camera to use (using first camera if not specified)')\r\n    print()\r\n\r\n\r\ndef abort(reason: str, return_code: int = 1, usage: bool = False):\r\n    print(reason + '\\n')\r\n\r\n    if usage:\r\n        print_usage()\r\n\r\n    sys.exit(return_code)\r\n\r\n\r\ndef parse_args() -\u003e Optional[str]:\r\n    args = sys.argv[1:]\r\n    argc = len(args)\r\n\r\n    for arg in args:\r\n        if arg in ('/h', '-h'):\r\n            print_usage()\r\n            sys.exit(0)\r\n\r\n    if argc \u003e 1:\r\n        abort(reason=\"Invalid number of arguments. Abort.\", return_code=2, usage=True)\r\n\r\n    return None if argc == 0 else args[0]\r\n\r\n\r\ndef get_camera(camera_id: Optional[str]) -\u003e Camera:\r\n    with VmbSystem.get_instance() as vmb:\r\n        if camera_id:\r\n            try:\r\n                return vmb.get_camera_by_id(camera_id)\r\n\r\n            except VmbCameraError:\r\n                abort('Failed to access Camera \\'{}\\'. Abort.'.format(camera_id))\r\n\r\n        else:\r\n            cams = vmb.get_all_cameras()\r\n            if not cams:\r\n                abort('No Cameras accessible. Abort.')\r\n            cam = cams[0]\r\n            cam.set_access_mode(AccessMode.Full)\r\n\r\n            return cams[0]\r\n\r\n\r\ndef setup_camera(cam: Camera):\r\n    #cam.set_access_mode(AccessMode.Full)\r\n\r\n    with cam:\r\n        #try to set the camera's config from an XML file\r\n        try:\r\n            print(cam.get_access_mode())\r\n            print(\"LOADING SETTINGS FROM XML\")\r\n            cam.load_settings(\"my_camera_settings.xml\", PersistType.All)\r\n        except (AttributeError, VmbFeatureError):\r\n            print(\"Failed to load settings from XML file\")\r\n            pass\r\n        \r\n        # # Enable auto exposure time setting if camera supports it\r\n    \r\n        # try:\r\n        #     cam.ExposureAuto.set('Continuous')\r\n\r\n        # except (AttributeError, VmbFeatureError):\r\n        #     pass\r\n\r\n        # # Enable white balancing if camera supports it\r\n        # try:\r\n        #     cam.BalanceWhiteAuto.set('Continuous')\r\n\r\n        # except (AttributeError, VmbFeatureError):\r\n        #     pass\r\n        \r\n        \r\n\r\n        # Try to adjust GeV packet size. This Feature is only available for GigE - Cameras.\r\n        try:\r\n            stream = cam.get_streams()[0]\r\n            stream.GVSPAdjustPacketSize.run()\r\n            while not stream.GVSPAdjustPacketSize.is_done():\r\n                pass\r\n\r\n        except (AttributeError, VmbFeatureError):\r\n            pass\r\n\r\n\r\ndef setup_pixel_format(cam: Camera):\r\n    # Query available pixel formats. Prefer color formats over monochrome formats\r\n    cam_formats = cam.get_pixel_formats()\r\n    cam_color_formats = intersect_pixel_formats(cam_formats, COLOR_PIXEL_FORMATS)\r\n    convertible_color_formats = tuple(f for f in cam_color_formats\r\n                                      if opencv_display_format in f.get_convertible_formats())\r\n\r\n    cam_mono_formats = intersect_pixel_formats(cam_formats, MONO_PIXEL_FORMATS)\r\n    convertible_mono_formats = tuple(f for f in cam_mono_formats\r\n                                     if opencv_display_format in f.get_convertible_formats())\r\n\r\n    # if OpenCV compatible color format is supported directly, use that\r\n    if opencv_display_format in cam_formats:\r\n        cam.set_pixel_format(opencv_display_format)\r\n\r\n    # else if existing color format can be converted to OpenCV format do that\r\n    elif convertible_color_formats:\r\n        cam.set_pixel_format(convertible_color_formats[0])\r\n\r\n    # fall back to a mono format that can be converted\r\n    elif convertible_mono_formats:\r\n        cam.set_pixel_format(convertible_mono_formats[0])\r\n\r\n    else:\r\n        abort('Camera does not support an OpenCV compatible format. Abort.')\r\n\r\n\r\nclass Handler:\r\n    def __init__(self):\r\n        self.display_queue = Queue(10)\r\n\r\n    def get_image(self):\r\n        return self.display_queue.get(True)\r\n\r\n    def __call__(self, cam: Camera, stream: Stream, frame: Frame):\r\n        if frame.get_status() == FrameStatus.Complete:\r\n            print('{} acquired {}'.format(cam, frame), flush=True)\r\n\r\n            # Convert frame if it is not already the correct format\r\n            if frame.get_pixel_format() == opencv_display_format:\r\n                display = frame\r\n            else:\r\n                # This creates a copy of the frame. The original `frame` object can be requeued\r\n                # safely while `display` is used\r\n                display = frame.convert_pixel_format(opencv_display_format)\r\n\r\n            self.display_queue.put(display.as_opencv_image(), True)\r\n\r\n        cam.queue_frame(frame)\r\n\r\n\r\ndef main():\r\n    print_preamble()\r\n    cam_id = parse_args()\r\n\r\n    with VmbSystem.get_instance():\r\n        with get_camera(cam_id) as cam:\r\n            # setup general camera settings and the pixel format in which frames are recorded\r\n            setup_camera(cam)\r\n            setup_pixel_format(cam)\r\n            handler = Handler()\r\n\r\n            try:\r\n                # Start Streaming with a custom a buffer of 10 Frames (defaults to 5)\r\n                cam.start_streaming(handler=handler, buffer_count=10)\r\n\r\n                msg = 'Stream from \\'{}\\'. Press \u003cEnter\u003e to stop stream.'\r\n                import cv2\r\n                ENTER_KEY_CODE = 13\r\n                while True:\r\n                    key = cv2.waitKey(1)\r\n                    if key == ENTER_KEY_CODE:\r\n                        cv2.destroyWindow(msg.format(cam.get_name()))\r\n                        break\r\n\r\n                    display = handler.get_image()\r\n                    #resize display to 1080p\r\n                    display = cv2.resize(display, (1920, 1080))\r\n                    cv2.imshow(msg.format(cam.get_name()), display)\r\n\r\n            finally:\r\n                cam.stop_streaming()\r\n\r\n\r\nif __name__ == '__main__':\r\n    main()\r\n\r\n```","author":{"url":"https://github.com/nparker2020","@type":"Person","name":"nparker2020"},"datePublished":"2024-01-05T17:16:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/178/VimbaPython/issues/178"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:fa1d34ab-282d-f40a-ee62-9153afa09f53
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB4FE:282357:2649441:35ED323:6A4CE480
html-safe-noncef56f097675dcd5eb5a60cb9ed399608a0c63d6b9bb4fa9227283e24b896c30e5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNEZFOjI4MjM1NzoyNjQ5NDQxOjM1RUQzMjM6NkE0Q0U0ODAiLCJ2aXNpdG9yX2lkIjoiNTQ2ODcyNzA4MTc2NzMzMDk0NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacbff3bcbb84985070b27b2d157ba73640512d6f765424ff7b4300555793907229
hovercard-subject-tagissue:2067729178
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/alliedvision/VimbaPython/178/issue_layout
twitter:imagehttps://opengraph.githubassets.com/983b9937c22cb41cf89e3ce057df6ad19728a0f19620b08468da9d47d8f7e47a/alliedvision/VimbaPython/issues/178
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/983b9937c22cb41cf89e3ce057df6ad19728a0f19620b08468da9d47d8f7e47a/alliedvision/VimbaPython/issues/178
og:image:altHello, I am modifying the asynchronous_grab_opencv.py example to set the camera's configuration from an XML file that I have, which contains exposure / color balance configuration that I like. Howe...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamenparker2020
hostnamegithub.com
expected-hostnamegithub.com
None299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8
turbo-cache-controlno-preview
go-importgithub.com/alliedvision/VimbaPython git https://github.com/alliedvision/VimbaPython.git
octolytics-dimension-user_id26818220
octolytics-dimension-user_loginalliedvision
octolytics-dimension-repository_id224388237
octolytics-dimension-repository_nwoalliedvision/VimbaPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id224388237
octolytics-dimension-repository_network_root_nwoalliedvision/VimbaPython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasec5a57f04eeb310f57c73fd6d751d957e2ca27ed2
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/alliedvision/VimbaPython/issues/178#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Falliedvision%2FVimbaPython%2Fissues%2F178
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Falliedvision%2FVimbaPython%2Fissues%2F178
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=alliedvision%2FVimbaPython
Reloadhttps://github.com/alliedvision/VimbaPython/issues/178
Reloadhttps://github.com/alliedvision/VimbaPython/issues/178
Reloadhttps://github.com/alliedvision/VimbaPython/issues/178
Please reload this pagehttps://github.com/alliedvision/VimbaPython/issues/178
alliedvision https://github.com/alliedvision
VimbaPythonhttps://github.com/alliedvision/VimbaPython
Notifications https://github.com/login?return_to=%2Falliedvision%2FVimbaPython
Fork 40 https://github.com/login?return_to=%2Falliedvision%2FVimbaPython
Star 92 https://github.com/login?return_to=%2Falliedvision%2FVimbaPython
Code https://github.com/alliedvision/VimbaPython
Issues 89 https://github.com/alliedvision/VimbaPython/issues
Pull requests 1 https://github.com/alliedvision/VimbaPython/pulls
Actions https://github.com/alliedvision/VimbaPython/actions
Projects https://github.com/alliedvision/VimbaPython/projects
Security and quality 0 https://github.com/alliedvision/VimbaPython/security
Insights https://github.com/alliedvision/VimbaPython/pulse
Code https://github.com/alliedvision/VimbaPython
Issues https://github.com/alliedvision/VimbaPython/issues
Pull requests https://github.com/alliedvision/VimbaPython/pulls
Actions https://github.com/alliedvision/VimbaPython/actions
Projects https://github.com/alliedvision/VimbaPython/projects
Security and quality https://github.com/alliedvision/VimbaPython/security
Insights https://github.com/alliedvision/VimbaPython/pulse
Unable to change PixelFormat with AccessMode.Fullhttps://github.com/alliedvision/VimbaPython/issues/178#top
https://github.com/nparker2020
nparker2020https://github.com/nparker2020
on Jan 5, 2024https://github.com/alliedvision/VimbaPython/issues/178#issue-2067729178
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.