v4l2


Getting framesize in V4L2 with VIDIOC_ENUM_FRAMESIZES


I'm trying to get the framesize that my fish-eye camera could provide.But I meet a hard problem that it always returns -1 when I use
ioctl(dev, VIDIOC_ENUM_FRAMESIZES, &fsize))
and the errno shows 22(invalid argument). Here is my main codes
Firstly, I get the format that the camera proviedes,where dev is camera's fd. In this part I can get format correctly.
int CameraV4L2::enum_frame_formats(int dev)
{
int ret;
struct v4l2_fmtdesc fmt;
memset(&fmt, 0, sizeof(fmt));
fmt.index = 0;
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
while ((ret = ioctl(dev, VIDIOC_ENUM_FMT, &fmt)) == 0)
{
fmt.index++;
printf("{ pixelformat = '%c%c%c%c', description = '%s' }\n",
fmt.pixelformat & 0xFF,
(fmt.pixelformat >> 8) & 0xFF,(fmt.pixelformat >> 16) & 0xFF,
(fmt.pixelformat >> 24) & 0xFF,fmt.description);
// get the framesize
ret = enum_frame_sizes(dev, fmt.pixelformat);
if (ret != 0)
{
printf(" Unable to enumerate frame sizes.\n");
}
}
if (errno != EINVAL)
{
printf("ERROR enumerating frame formats: %d\n", errno);
return errno;
}
return 0;
}
Secondly, I get framesize in each format. In this part the option
ioctl(dev, VIDIOC_ENUM_FRAMESIZES, &fsize))
always returns -1 with errno 22
CameraV4L2::enum_frame_sizes(int dev, __u32 pixfmt)
{
int ret;
struct v4l2_frmsizeenum fsize;
memset(&fsize, 0, sizeof(fsize));
fsize.index = 0;
fsize.pixel_format = pixfmt;
while ((ret = ioctl(dev, VIDIOC_ENUM_FRAMESIZES, &fsize)) == 0)
{
printf("run here1");
if (fsize.type == V4L2_FRMSIZE_TYPE_DISCRETE)
{
printf("run here1");
printf("{ discrete: width = %u, height = %u}\n",
fsize.discrete.width, fsize.discrete.height);
// get frame rate
ret = enum_frame_intervals(dev,pixfmt,fsize.discrete.width,
fsize.discrete.height);
if (ret != 0)
{
printf(" Unable to enumerate frame sizes.\n");
}
}
else if (fsize.type == V4L2_FRMSIZE_TYPE_CONTINUOUS)
{
printf("{ continuous: min { width = %u, height = %u } .. "
"max { width = %u, height = %u } }\n",
fsize.stepwise.min_width,
fsize.stepwise.min_height,
fsize.stepwise.max_width,
fsize.stepwise.max_height);
printf(" Refusing to enumerate frame intervals.\n");
break;
}
else if (fsize.type == V4L2_FRMSIZE_TYPE_STEPWISE)
{
printf("run here3");
printf("{ stepwise: min { width = %u, height = %u } .. "
"max { width = %u, height = %u } / "
"stepsize { width = %u, height = %u } }\n",
fsize.stepwise.min_width,
fsize.stepwise.min_height,
fsize.stepwise.max_width,
fsize.stepwise.max_height,
fsize.stepwise.step_width,
fsize.stepwise.step_height);
printf(" Refusing to enumerate frame intervals.\n");
break;
}
else
{
printf("no type");
}
fsize.index++;
}
if (ret != 0 || errno != EINVAL)
{
printf("ERROR enumerating frame sizes: %d\n", errno);
return errno;
}
return 0;
}
In the third part I get the frame rate. I will not copy codes here because it doesn't contain my question.
Here is my output:
{ pixelformat = 'RGBO', description = '15 bpp RGB, le' }
RERROR enumerating frame sizes: 22
Unable to enumerate frame sizes.
{ pixelformat = 'RGBP', description = '16 bpp RGB, le' }
RERROR enumerating frame sizes: 22
Unable to enumerate frame sizes.
{ pixelformat = 'YUYV', description = '4:2:2 packed, YUYV' }
YERROR enumerating frame sizes: 22
Unable to enumerate frame sizes.
{ pixelformat = 'UYVY', description = '4:2:2 packed, UYVY' }
UERROR enumerating frame sizes: 22
Unable to enumerate frame sizes.
it does contain format but no framesize, So how can I fix my problem? Thank you!

Related Links

V4L2 frame rate maxes out at ~10FPS… why?
Any known-to-work example in C using VIDIOC_S_CROP in V4L2?
Getting framesize in V4L2 with VIDIOC_ENUM_FRAMESIZES
A4Tech webcam and avconv (ffmpeg) captures same frame all the time
yavta cause kernel panic (ov5640 with DM3730)
V4L2 preview with callback instead of polling-loop
Function call ioctl with VIDIOC_QUERYCAP request doesn't return
V4L2 difference between JPEG and MJPEG pixel formats
v4l2-ctl not changing from default webcam
Where I can find example in using v4l2 codec driver
Timestamp for v4l2 image capture
Where does v4l2_buffer->timestamp value starts counting?

Categories

HOME
pact
airflow
indexing
macros
postgresql-9.3
opc-ua
snmp
symfony-3.2
liquidsoap
schema
qt4
webpack-dev-server
http-status-codes
jetbrains
minimum
responsive
openstack-horizon
luis
loss
k-means
filehelpers
wallet
google-calendar-api3
spring-webflow
datasource
connectiq
beaker-notebook
fastboot
prepros
ps
jopendocument
workflow-foundation
angular2-changedetection
sqldependency
arp
postgresql-9.6
snapkit
offset
wit-ai
campaign-monitor
mapquest
gem-fury
ninja-forms
redbean
flume-ng
colorbox
peerjs
nshttpurlresponse
angular-fullstack
togglebutton
runner
stream-socket-client
hdpi
dna-sequence
sharpdevelop
gige-sdk
openpgp.js
webmatrix
cc
bipartite
lightspeed
timefield
mac-app-store
ldd
access-violation
class-design
sprockets
nsoperationqueue
sbt-proguard
window.location
android-progressbar
ooad
std
bioconductor
mojolicious
gitk
jts
android-togglebutton
p4python
maven-archetype
beagleboard
strcpy
numerical-recipes
douglas-peucker
iphone-6
diffmerge
api-eveonline
new-operator
starling-framework
mongoid4
xml-validation
mandelbrot
stringstream
dnsbl
antixsslibrary
configurationsection
doxia
derived-class
waveout
dancer
towerjs
ruby-1.9
overlays
hs-err
xcdatamodel
mediastreamsource
dongle
data-formats
authkit

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile