Hi
On an IMX93evk card with Yocto
I tested the code below intended to do an image acquisition on the /dev/video device connected to a RPI-CAM-MIPI camera
https://docs.nxp.com/bundle/UM11933/page/topics/rpi-cam-mipi_overview.html
The calls to the ioctl function fail.
Curiously OpenCv makes the same calls and they do not fail
What did I miss?
int main() {
const char *device = "/dev/video0";
int fd = open(device, O_RDWR);
if (fd == -1) {
perror("Opening video device");
return 1;
}
struct v4l2_format format;
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
format.fmt.pix.width = 640;
format.fmt.pix.height = 480;
format.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
format.fmt.pix.field = V4L2_FIELD_INTERLACED;
if (ioctl(fd, VIDIOC_S_FMT, &format) < 0) {
perror("Setting Pixel Format");
return 1;
}
struct v4l2_requestbuffers req;
memset(&req, 0, sizeof(req));
req.count = 1;
req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
req.memory = V4L2_MEMORY_MMAP;
if (ioctl(fd, VIDIOC_REQBUFS, &req) < 0) {
perror("Requesting Buffer");
return 1;
}
struct v4l2_buffer buf;
memset(&buf, 0, sizeof(buf));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
buf.memory = V4L2_MEMORY_MMAP;
buf.index = 0;
if (ioctl(fd, VIDIOC_QUERYBUF, &buf) < 0) {
perror("Querying Buffer");
return 1;
}
解決済! 解決策の投稿を見る。
hi
I solved this problem using
https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/173737/1/v4lcap.c
Greetings
Olivier
Hi,
Thank you for your interest in NXP Semiconductor products,
Are you able to replicate the camera preview in your setup?
$ media-ctl -p
$ v4l2-ctl --list-devices
List the supported pixel formats:
$ v4l2-ctl -d0 --list-formats
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture Multiplanar
...
List the supported image resolutions:
$ v4l2-ctl -d0 --list-framesizes YUYV
ioctl: VIDIOC_ENUM_FRAMESIZES
Size: Discrete 1920x1080
...
Capture the camera data and save them to a file using the "v4l2-ctl" command. The supported pixel formats and resolutions are listed above. Here is an example to capture the 1280x800 YUYV camera data:
$ v4l2-ctl -d0 --set-fmt-video=width=1280,height=800,pixelformat=YUYV --stream-mmap=4 --stream-count=10 --stream-to=test.yuv
Capture the camera data, preview them on screen or save them to a file using the "gstreamer" commands:
# preview on screen
$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! "video/x-raw,format=YUY2,width=1280,height=800" ! queue ! waylandsink
Regards
hi
I solved this problem using
https://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors/173737/1/v4lcap.c
Greetings
Olivier