DXcam
DXcam copied to clipboard
Win10 screenshot is black
dxcam.device_info() : Device[0]:<Device Name:Intel(R) UHD Graphics 630 Dedicated VRAM:128Mb VendorId:32902> there is a problem ,it is not my NVIDIA 1050
dxcam.output_info() : Device[0] Output[0]: Res:(1920, 1080) Rot:0 Primary:True
Windows10 and python 3.8.13
when i use following code , it works,
d = dxcam.create(device_idx=0, output_idx=0)
img = d.grab()
Image.fromarray(img).show()
but this code go wrong
import dxcam
camera = dxcam.create()
from PIL import Image
Image.fromarray(frame).show()
following code,i run this code ,the non is 22383, this mean every 23 pic just have 1 valid pic ,i think you should add a judge ,when the grab
return none ,try again
import time
import dxcam
TOP = 0
LEFT = 0
RIGHT = 1920
BOTTOM = 1080
region = (LEFT, TOP, RIGHT, BOTTOM)
title = "[DXcam] FPS benchmark"
start_time = time.time()
non = 0
fps = 0
cam = dxcam.create()
start = time.perf_counter()
while fps < 1000:
frame = cam.grab(region=region)
print(fps)
if frame is not None:
fps += 1
else :
non = non +1
end_time = time.time() - start_time
print(f"{title}: {fps/end_time}")
print(non)
del cam
when i use your start
func , it raise OSError: [WinError 87]
,i find the error is caused by fowllowing code in your timer.py.
the res == 0
def set_periodic_timer(handle, period: int):
res = __kernel32.SetWaitableTimer(
handle,
ctypes.byref(LARGE_INTEGER(0)),
period,
None,
None,
0,
)
if res == 0:
raise ctypes.WinError()
return True
following code,i run this code ,the non is 22383, this mean every 23 pic just have 1 valid pic ,i think you should add a judge ,when the
grab
return none ,try again
From README.md: " It is worth noting that .grab will return None if there is no new frame since the last time you called .grab. Usually it means there's nothing new to render since last time (E.g. You are idling). "
but this code go wrong
import dxcam camera = dxcam.create() from PIL import Image Image.fromarray(frame).show()
Could you supply the full working code to reproduce the issue you mentioned? Also, for your 1050, is it a laptop GPU using hybrid system or is it on your desktop?
but this code go wrong
import dxcam camera = dxcam.create() from PIL import Image Image.fromarray(frame).show()
Could you supply the full working code to reproduce the issue you mentioned? Also, for your 1050, is it a laptop GPU using hybrid system or is it on your desktop?
i find it works ok,it is another problem ,i dont know if you know, grab
will return a black pic , but the grab
also return valid pic ,this mean grab
will return None
,a black pic (it is a array which is all zero),and a valid pic ,although it that the func return a black pic occur few
i say" the grab
goes wrong",it actully is the first pic that the grab
return is a black pic ,may be the second is a black pic too ,but after some 'None' or black pic , the 'grab' will return a vaild pic
and the start
raise error,
when i use your
start
func , it raiseOSError: [WinError 87]
,i find the error is caused by fowllowing code in your timer.py. theres == 0
def set_periodic_timer(handle, period: int): res = __kernel32.SetWaitableTimer( handle, ctypes.byref(LARGE_INTEGER(0)), period, None, None, 0, ) if res == 0: raise ctypes.WinError() return True
following is my display and systme information
------------------
System Information
------------------
Time of this report: 6/8/2022, 11:51:30
Machine name: SKY-20220528OXO
Machine Id: {A4887C2B-E736-4EF1-AE50-A4EC9416D63A}
Operating System: Windows 10 LTSC 64-bit (10.0, Build 17763) (17763.rs5_release.180914-1434)
Language: Chinese (Simplified) (Regional Setting: Chinese (Simplified))
System Manufacturer: HASEE Computer
System Model: N8xEJEK
BIOS: 1.07.11RHZX1 (type: UEFI)
Processor: Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz (8 CPUs), ~2.3GHz
Memory: 8192MB RAM
Available OS Memory: 8040MB RAM
Page File: 5989MB used, 4664MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 12
DX Setup Parameters: Not found
User DPI Setting: 96 DPI (100 percent)
System DPI Setting: 120 DPI (125 percent)
DWM DPI Scaling: Disabled
Miracast: Available, with HDCP
Microsoft Graphics Hybrid: Supported
DxDiag Version: 10.00.17763.0001 64bit Unicode
------------
DxDiag Notes
------------
Display Tab 1: No problems found.
Display Tab 2: No problems found.
Sound Tab 1: No problems found.
Input Tab: No problems found.
--------------------
DirectX Debug Levels
--------------------
Direct3D: 0/4 (retail)
DirectDraw: 0/4 (retail)
DirectInput: 0/5 (retail)
DirectMusic: 0/5 (retail)
DirectPlay: 0/9 (retail)
DirectSound: 0/5 (retail)
DirectShow: 0/6 (retail)
---------------
Display Devices
---------------
Card name: Intel(R) UHD Graphics 630
Manufacturer: Intel Corporation
Chip type: Intel(R) UHD Graphics Family
DAC type: Internal
Device Type: Full Device (POST)
Device Key: Enum\PCI\VEN_8086&DEV_3E9B&SUBSYS_852B1558&REV_00
Device Status: 0180200A [DN_DRIVER_LOADED|DN_STARTED|DN_DISABLEABLE|DN_NT_ENUMERATOR|DN_NT_DRIVER]
Device Problem Code: No Problem
Driver Problem Code: Unknown
Display Memory: 4148 MB
Dedicated Memory: 128 MB
Shared Memory: 4020 MB
Current Mode: 1920 x 1080 (32 bit) (60Hz)
HDR Support: Not Supported
Display Topology: Internal
Display Color Space: DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709
Color Primaries: Red(0.591797,0.360352), Green(0.341797,0.556641), Blue(0.158203,0.109375), White Point(0.313477,0.329102)
Display Luminance: Min Luminance = 0.500000, Max Luminance = 270.000000, MaxFullFrameLuminance = 270.000000
Monitor Name: Generic PnP Monitor
Monitor Model: LM156LF1L03
Monitor Id: NCP001C
Native Mode: 1920 x 1080(p) (59.997Hz)
Output Type: Internal
Monitor Capabilities: HDR Not Supported
Display Pixel Format: DISPLAYCONFIG_PIXELFORMAT_32BPP
Advanced Color: Not Supported
Driver Name: C:\WINDOWS\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_a6f2bd19df3d42e0\igdumdim64.dll,C:\WINDOWS\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_a6f2bd19df3d42e0\igd10iumd64.dll,C:\WINDOWS\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_a6f2bd19df3d42e0\igd10iumd64.dll,C:\WINDOWS\System32\DriverStore\FileRepository\iigd_dch.inf_amd64_a6f2bd19df3d42e0\igd12umd64.dll
Driver File Version: 30.00.0101.1191 (English)
Driver Version: 30.0.101.1191
DDI Version: 12
Feature Levels: 12_1,12_0,11_1,11_0,10_1,10_0,9_3,9_2,9_1
Driver Model: WDDM 2.5
Graphics Preemption: Triangle
Compute Preemption: Thread
Miracast: Supported
Hybrid Graphics GPU: Integrated
Power P-states: Not Supported
Virtualization: Paravirtualization
Block List: No Blocks
Catalog Attributes: Universal:False Declarative:True
Driver Attributes: Final Retail
Driver Date/Size: 2021/12/3 8:00:00, 1466080 bytes
WHQL Logo'd: n/a
WHQL Date Stamp: n/a
Device Identifier: {D7B78E66-7DDB-11CF-4F72-4EA5AFC2D335}
Vendor ID: 0x8086
Device ID: 0x3E9B
SubSys ID: 0x852B1558
Revision ID: 0x0000
Driver Strong Name: oem15.inf:5f63e53429d61c21:iCFL_w10_DS:30.0.101.1191:PCI\VEN_8086&DEV_3E9B
Rank Of Driver: 00CF2001
Video Accel: ModeMPEG2_A ModeMPEG2_C ModeWMV9_C ModeVC1_C
DXVA2 Modes: DXVA2_ModeMPEG2_VLD DXVA2_ModeMPEG2_IDCT DXVA2_ModeVC1_D2010 DXVA2_ModeWMV9_IDCT DXVA2_ModeVC1_IDCT DXVA2_ModeH264_VLD_NoFGT DXVA2_ModeH264_VLD_Stereo_Progressive_NoFGT DXVA2_ModeH264_VLD_Stereo_NoFGT DXVA2_ModeH264_VLD_Multiview_NoFGT DXVA2_ModeVP8_VLD DXVA2_ModeHEVC_VLD_Main DXVA2_ModeHEVC_VLD_Main10 DXVA2_ModeVP9_VLD_Profile0 DXVA2_ModeVP9_VLD_10bit_Profile2
Deinterlace Caps: {BF752EF6-8CC4-457A-BE1B-08BD1CAEEE9F}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_EdgeFiltering
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_BOBVerticalStretch
{5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(YUY2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend
{BF752EF6-8CC4-457A-BE1B-08BD1CAEEE9F}: Format(In/Out)=(UYVY,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_EdgeFiltering
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(UYVY,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_BOBVerticalStretch
{5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(UYVY,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend
{BF752EF6-8CC4-457A-BE1B-08BD1CAEEE9F}: Format(In/Out)=(YV12,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_EdgeFiltering
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(YV12,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_BOBVerticalStretch
{5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(YV12,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend
{BF752EF6-8CC4-457A-BE1B-08BD1CAEEE9F}: Format(In/Out)=(NV12,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_EdgeFiltering
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(NV12,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_BOBVerticalStretch
{5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(NV12,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend
{BF752EF6-8CC4-457A-BE1B-08BD1CAEEE9F}: Format(In/Out)=(IMC1,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_EdgeFiltering
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(IMC1,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_BOBVerticalStretch
{5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC1,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend
{BF752EF6-8CC4-457A-BE1B-08BD1CAEEE9F}: Format(In/Out)=(IMC2,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_EdgeFiltering
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(IMC2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_BOBVerticalStretch
{5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC2,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend
{BF752EF6-8CC4-457A-BE1B-08BD1CAEEE9F}: Format(In/Out)=(IMC3,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_EdgeFiltering
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(IMC3,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_BOBVerticalStretch
{5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC3,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend
{BF752EF6-8CC4-457A-BE1B-08BD1CAEEE9F}: Format(In/Out)=(IMC4,YUY2) Frames(Prev/Fwd/Back)=(0,0,1) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_EdgeFiltering
{335AA36E-7884-43A4-9C91-7F87FAF3E37E}: Format(In/Out)=(IMC4,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend DeinterlaceTech_BOBVerticalStretch
{5A54A0C9-C7EC-4BD9-8EDE-F3C75DC4393B}: Format(In/Out)=(IMC4,YUY2) Frames(Prev/Fwd/Back)=(0,0,0) Caps=VideoProcess_YUV2RGB VideoProcess_StretchX VideoProcess_StretchY VideoProcess_AlphaBlend
D3D9 Overlay: Supported
DXVA-HD: Supported
DDraw Status: Enabled
D3D Status: Enabled
AGP Status: Enabled
MPO MaxPlanes: 3
MPO Caps: RGB,YUV,BILINEAR,HIGH_FILTER,STRETCH_YUV,STRETCH_RGB,IMMEDIATE,HDR (MPO3)
MPO Stretch: 5.000X - 0.334X
MPO Media Hints: colorspace Conversion
MPO Formats: NV12,YUY2,R16G16B16A16_FLOAT,R10G10B10A2_UNORM,R8G8B8A8_UNORM,B8G8R8A8_UNORM
PanelFitter Caps: RGB,YUV,BILINEAR,HIGH_FILTER,STRETCH_YUV,STRETCH_RGB,IMMEDIATE,HDR (MPO3)
PanelFitter Stretch: 5.000X - 0.334X
Component Drivers:
Driver Name: Unknown
Driver Version: Unknown
Driver Date: Unknown
Driver Provider: Unknown
Catalog Attributes: N/A
Driver Name: Unknown
Driver Version: Unknown
Driver Date: Unknown
Driver Provider: Unknown
Catalog Attributes: N/A
Card name: NVIDIA GeForce GTX 1050
Manufacturer: NVIDIA
Chip type: NVIDIA GeForce GTX 1050
DAC type: Integrated RAMDAC
Device Type: Full Device
Device Key: Enum\PCI\VEN_10DE&DEV_1C8D&SUBSYS_852B1558&REV_A1
Device Status: 0180200A [DN_DRIVER_LOADED|DN_STARTED|DN_DISABLEABLE|DN_NT_ENUMERATOR|DN_NT_DRIVER]
Device Problem Code: No Problem
Driver Problem Code: Unknown
Display Memory: 8039 MB
Dedicated Memory: 4019 MB
Shared Memory: 4020 MB
Current Mode: Unknown
HDR Support: Unknown
Display Topology: Unknown
Display Color Space: Unknown
Color Primaries: Unknown
Display Luminance: Unknown
Driver Name: C:\WINDOWS\System32\DriverStore\FileRepository\nvcvi.inf_amd64_a7f040d412e68b48\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nvcvi.inf_amd64_a7f040d412e68b48\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nvcvi.inf_amd64_a7f040d412e68b48\nvldumdx.dll,C:\WINDOWS\System32\DriverStore\FileRepository\nvcvi.inf_amd64_a7f040d412e68b48\nvldumdx.dll
Driver File Version: 30.00.0014.7212 (English)
Driver Version: 30.0.14.7212
DDI Version: 12
Feature Levels: 12_1,12_0,11_1,11_0,10_1,10_0,9_3,9_2,9_1
Driver Model: WDDM 2.5
Graphics Preemption: Pixel
Compute Preemption: Dispatch
Miracast: Not Supported by Graphics driver
Hybrid Graphics GPU: Discrete
Power P-states: Not Supported
Virtualization: Paravirtualization
Block List: No Blocks
Catalog Attributes: Universal:False Declarative:False
Driver Attributes: Final Retail
Driver Date/Size: 2021/9/13 8:00:00, 1056280 bytes
WHQL Logo'd: n/a
WHQL Date Stamp: n/a
Device Identifier: Unknown
Vendor ID: 0x10DE
Device ID: 0x1C8D
SubSys ID: 0x852B1558
Revision ID: 0x00A1
Driver Strong Name: oem19.inf:0f066de32d346075:Section160:30.0.14.7212:pci\ven_10de&dev_1c8d&subsys_852b1558
Rank Of Driver: 00D10001
Video Accel: Unknown
DXVA2 Modes: DXVA2_ModeMPEG2_VLD DXVA2_ModeVC1_D2010 DXVA2_ModeVC1_VLD DXVA2_ModeH264_VLD_Stereo_Progressive_NoFGT DXVA2_ModeH264_VLD_Stereo_NoFGT DXVA2_ModeH264_VLD_NoFGT DXVA2_ModeHEVC_VLD_Main DXVA2_ModeHEVC_VLD_Main10 DXVA2_ModeMPEG4pt2_VLD_Simple DXVA2_ModeMPEG4pt2_VLD_AdvSimple_NoGMC DXVA2_ModeVP9_VLD_Profile0 DXVA2_ModeVP9_VLD_10bit_Profile2
Deinterlace Caps: n/a
D3D9 Overlay: Unknown
DXVA-HD: Unknown
DDraw Status: Enabled
D3D Status: Enabled
AGP Status: Enabled
MPO MaxPlanes: 0
MPO Caps: Not Supported
MPO Stretch: Not Supported
MPO Media Hints: Not Supported
MPO Formats: Not Supported
PanelFitter Caps: Not Supported
PanelFitter Stretch: Not Supported
This was also encoutered by me. After ruling out those black and None frames, I got only 15 valid pictures per second.
This was also encoutered by me. After ruling out those black and None frames, I got only 15 valid pictures per second.
Did you make sure that the output constantly has new frames to render during testing? (See benchmark section in readme)
I had this issue but I just put a time.sleep(0.1) after create and grab doesn't return a black image anymore.
camera = dxcam.create()
time.sleep(0.1)
frame = camera.grab()
Closing -- the temporary workaround will be add time.sleep(0.1) after create the camera instance. Will be added in the constructor by default in upcoming release