MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / SetCameraFormat

Function SetCameraFormat

tensorflow/contrib/pi_examples/camera/camera.cc:91–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89}
90
91Status SetCameraFormat(int camera_handle, int wanted_width, int wanted_height) {
92 struct v4l2_format fmt;
93 memset(&fmt, 0, sizeof(fmt));
94 fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
95 fmt.fmt.pix.width = wanted_width;
96 fmt.fmt.pix.height = wanted_height;
97 fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24;
98 fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
99 Status set_format_status =
100 SendCameraCommand(camera_handle, VIDIOC_S_FMT, &fmt);
101 if (!set_format_status.ok()) {
102 LOG(ERROR) << "Setting format failed with " << set_format_status;
103 return set_format_status;
104 }
105 if (fmt.fmt.pix.pixelformat != V4L2_PIX_FMT_RGB24) {
106 LOG(ERROR) << "Libv4l didn't accept RGB24 format. Can't proceed.";
107 return tensorflow::errors::Unknown("Libv4l didn't accept RGB24 format");
108 }
109 if ((fmt.fmt.pix.width != wanted_width) ||
110 (fmt.fmt.pix.height != wanted_height)) {
111 LOG(WARNING) << "Warning: driver is sending image at " << fmt.fmt.pix.width
112 << "x" << fmt.fmt.pix.height;
113 }
114 return Status::OK();
115}
116
117Status StartCameraCapture(int camera_handle, int buffer_count,
118 CameraBuffer** buffers) {

Callers 1

mainFunction · 0.85

Calls 3

SendCameraCommandFunction · 0.85
UnknownFunction · 0.50
okMethod · 0.45

Tested by

no test coverage detected