{"id":9710,"library":"dxcam","title":"DXcam - High-Performance Windows Screenshot Library","description":"DXcam is a Python library providing high-performance screenshot capabilities specifically for Windows, leveraging the Desktop Duplication API. It's currently at version 0.3.0 and sees active development with irregular but significant updates, focusing on performance, backend options, and robustness.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/ra1nty/DXcam","tags":["windows","screenshot","desktop-duplication-api","performance","graphics"],"install":[{"cmd":"pip install dxcam","lang":"bash","label":"Basic Install"},{"cmd":"pip install dxcam opencv-python numpy","lang":"bash","label":"Install with common dependencies for image processing"}],"dependencies":[{"reason":"Used for efficient array manipulation of captured frames; essential for many processing backends.","package":"numpy","optional":false},{"reason":"Commonly used for image processing with captured frames, and one of DXcam's processor backends.","package":"opencv-python","optional":true}],"imports":[{"wrong":"import dxcam","symbol":"dxcam","correct":"import dxcam"}],"quickstart":{"code":"import dxcam\nimport cv2\n\n# dxcam is Windows-only, so this example will only run there.\n# On other OS, it will raise a RuntimeError.\n\ntry:\n    # Create a DXcam instance, auto-detecting the primary display output.\n    # Optionally specify output_idx, region, or device_idx.\n    camera = dxcam.create()\n\n    if camera is None:\n        print(\"Failed to create DXcam instance. Ensure a display is connected and drivers are up to date.\")\n    else:\n        # Start capturing frames. By default, it captures the full screen.\n        camera.start(target_fps=30)\n\n        # Grab a single frame\n        frame = camera.grab()\n\n        if frame is not None:\n            print(f\"Captured frame with shape: {frame.shape}, dtype: {frame.dtype}\")\n            # Example: Display the frame using OpenCV (requires opencv-python)\n            cv2.imshow('DXcam Frame', frame)\n            cv2.waitKey(1000) # Display for 1 second\n            cv2.destroyAllWindows()\n        else:\n            print(\"Failed to grab a frame.\")\n\n        # Stop capturing frames when done\n        camera.stop()\n\nexcept RuntimeError as e:\n    print(f\"Error initializing DXcam: {e}. DXcam is a Windows-only library.\")\nexcept ImportError as e:\n    print(f\"Missing required dependency for quickstart: {e}. Try 'pip install dxcam opencv-python numpy'.\")\n","lang":"python","description":"This quickstart initializes DXcam, starts capturing, grabs a single frame, and displays it using OpenCV (if installed). It includes error handling for non-Windows environments and initialization failures."},"warnings":[{"fix":"Ensure your development and deployment environment is Windows. Consider conditional imports or platform checks if your application needs to support multiple OS.","message":"DXcam is a Windows-only library. Attempting to import or use it on other operating systems will result in a RuntimeError.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Thoroughly test performance and stability when migrating from versions prior to 0.1.0. Monitor for `DXGI_ERROR_DEVICE_REMOVED` or unexpected frame drops.","message":"Version 0.1.0 introduced a 'Major overhaul', switching the default capture path to `IDXGIOutput5.DuplicateOutput1` and changing frame transfer from `CopyResource` to `CopySubresourceRegion`. This may alter performance characteristics or reveal new issues if upgrading from pre-0.1.0 versions, especially for applications sensitive to low-level capture behavior.","severity":"breaking","affected_versions":"<0.1.0 to >=0.1.0"},{"fix":"Consult the DXcam documentation to understand the different backends and processors. Experiment with `processor='numpy_kernels'` or `processor='cv2'` (if `opencv-python` is installed) and different `backend` options to find the best fit for your use case.","message":"Version 0.2.0 introduced a WinRT backend and new processor splits (cv2 backend / numpy Cython-kernel backend). While this adds flexibility, users relying on specific performance profiles from earlier versions might need to re-evaluate their chosen backend/processor for optimal results.","severity":"gotcha","affected_versions":">=0.2.0"},{"fix":"Implement robust error handling for `None` frames returned by `grab()`. Consider re-initializing the DXcam instance if errors persist or if the display configuration changes significantly. Version 0.3.0 improved handling of DXGI mode switches, but device removal remains a challenge.","message":"DXcam relies on the Desktop Duplication API, which can encounter 'device lost' scenarios (e.g., monitor unplugged, GPU driver reset, display mode change). While DXcam attempts to recover, persistent issues can lead to `None` frames or crashes.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.3.0':32 'activ':35 'api':26,54 'backend':45 'capabl':18 'current':29 'desktop':24,52 'desktop-duplication-api':51 'develop':36 'duplic':25,53 'dxcam':1,8 'focus':42 'graphic':56 'high':3,15 'high-perform':2,14 'irregular':38 'leverag':22 'librari':7,12 'option':46 'perform':4,16,44,55 'provid':13 'python':11 'robust':48 'screenshot':6,17,50 'see':34 'signific':40 'specif':19 'updat':41 'version':31 'window':5,21,49","created_at":"2026-04-17T01:20:19.522874+00:00","updated_at":"2026-04-17T01:20:19.522874+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"/tmp/tmpbr9b1m1o/venv/lib/python3.12/site-packages/comtypes/__init__.py\", line 5, in <module>\n    from _ctypes import COMError  # noqa\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nImportError: cannot import name 'COMError' from '_ctypes' (/home/xor/anaconda3/lib/python"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.3.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/ra1nty/DXcam","docs":null,"changelog":null,"pypi":"https://pypi.org/project/dxcam/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}