Closed virtuald closed 5 years ago
We could decode non-UTF-8 strings as latin1. But then the question arises of what happens when a user tries to set the property to that value.
Would it even be possible to set non-UTF-8 string values? Is it possible to pass in bytes?
I'm not sure what happens if we store bytes in pynetworktables (even though this is clearly what the C ntcore implementation must be doing). I think the python version will try to convert it to a string, which will fail.
If anyone has a camera that causes this issue, to address this we first need to know what the bytes returned by the camera are. The best way to do this is to (a) identify what key is causing the issue (typically it's the camera name) and (b) get the bytes (using... some program? A good start would be the output of v4l2-ctl --all
or some similar program).
@PeterJohnson points out that we should give a better warning when a encoding/decoding error occurs. Perhaps something that mentions what key failed.
I'm encountering this problem using a Pi NoIR Camera (https://www.amazon.com/Arducam-Camera-Raspberry-Interchangeable-LS-2717CS/dp/B013JV4Z7K/ref=sr_1_4?ie=UTF8&qid=1548005788&sr=8-4&keywords=noir+camera+pi).
This is the result from running v412-ctl --all:
Driver Info (not using libv4l2):
Driver name : bm2835 mmal
Card type : mmal service 16.1
Bus info : platform:bcm2835-v4l2
Driver version: 4.14.79
Capabilities : 0x85200005
Video Capture
Video Overlay
Read/Write
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x05200005
Video Capture
Video Overlay
Read/Write
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 0: ok)
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'MJPG'
Field : None
Bytes per Line : 0
Size Image : 307200
Colorspace : SMPTE 170M
Transfer Function : Default
YCbCr/HSV Encoding: Default
Quantization : Default
Flags :
Format Video Overlay:
Left/Top : 150/50
Width/Height: 1024/768
Field : None
Chroma Key : 0x00000000
Global Alpha: 0xff
Clip Count : 0
Clip Bitmap : No
Framebuffer Format:
Capability : Extern Overlay
Global Alpha
Flags : Overlay Matches Capture/Output Size
Width : 640
Height : 480
Pixel Format : 'YU12'
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 1
User Controls
brightness (int) : min=0 max=100 step=1 default=50 value=50 flags=slider
contrast (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
saturation (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
red_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
blue_balance (int) : min=1 max=7999 step=1 default=1000 value=1000 flags=slider
horizontal_flip (bool) : default=0 value=0
vertical_flip (bool) : default=0 value=0
power_line_frequency (menu) : min=0 max=3 default=1 value=1
sharpness (int) : min=-100 max=100 step=1 default=0 value=0 flags=slider
color_effects (menu) : min=0 max=15 default=0 value=0
rotate (int) : min=0 max=360 step=90 default=0 value=0 flags=00000400
color_effects_cbcr (int) : min=0 max=65535 step=1 default=32896 value=32896
Codec Controls
video_bitrate_mode (menu) : min=0 max=1 default=0 value=0 flags=update
video_bitrate (int) : min=25000 max=25000000 step=25000 default=10000000 value=10000000
repeat_sequence_header (bool) : default=0 value=0
h264_i_frame_period (int) : min=0 max=2147483647 step=1 default=60 value=60
h264_level (menu) : min=0 max=11 default=11 value=11
h264_profile (menu) : min=0 max=4 default=4 value=4
Camera Controls
auto_exposure (menu) : min=0 max=3 default=0 value=0
exposure_time_absolute (int) : min=1 max=10000 step=1 default=1000 value=1
exposure_dynamic_framerate (bool) : default=0 value=0
auto_exposure_bias (intmenu): min=0 max=24 default=12 value=12
white_balance_auto_preset (menu) : min=0 max=9 default=1 value=1
image_stabilization (bool) : default=0 value=0
iso_sensitivity (intmenu): min=0 max=4 default=0 value=0
iso_sensitivity_auto (menu) : min=0 max=1 default=1 value=1
exposure_metering_mode (menu) : min=0 max=2 default=0 value=0
scene_mode (menu) : min=0 max=13 default=0 value=0
JPEG Compression Controls
compression_quality (int) : min=1 max=100 step=1 default=30 value=30
Any other way in which I could help?
The problem is the intmenu's. cscore does the wrong thing when converting the enum value names. I opened a PR to fix this in wpilibsuite/allwpilib#1561.
We fixed a problem similar to this previously.
https://www.chiefdelphi.com/t/trouble-running-the-python-example-code-with-wpilib-frcvision-raspberry-pi-image/342147/2
Would be good to identify the string in question and figure out the right way to convert it to unicode.