Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libuvc_ros
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mobile_robotics
ADC
external
libuvc_ros
Commits
4b74f518
Commit
4b74f518
authored
9 years ago
by
Ken Tossell
Browse files
Options
Downloads
Plain Diff
Merge pull request #27 from joshvillbrandt/feat/open-camera-index
Implement missing index select behavior
parents
b4486d97
4f30e9a0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libuvc_camera/src/camera_driver.cpp
+25
-6
25 additions, 6 deletions
libuvc_camera/src/camera_driver.cpp
with
25 additions
and
6 deletions
libuvc_camera/src/camera_driver.cpp
+
25
−
6
View file @
4b74f518
...
...
@@ -309,19 +309,38 @@ void CameraDriver::OpenCamera(UVCCameraConfig &new_config) {
ROS_INFO
(
"Opening camera with vendor=0x%x, product=0x%x, serial=
\"
%s
\"
, index=%d"
,
vendor_id
,
product_id
,
new_config
.
serial
.
c_str
(),
new_config
.
index
);
uvc_error_t
find_err
=
uvc_find_device
(
ctx_
,
&
dev_
,
uvc_device_t
**
devs
;
uvc_error_t
find_err
=
uvc_find_devices
(
ctx_
,
&
devs
,
vendor_id
,
product_id
,
new_config
.
serial
.
empty
()
?
NULL
:
new_config
.
serial
.
c_str
());
// TODO: index
if
(
find_err
!=
UVC_SUCCESS
)
{
uvc_perror
(
find_err
,
"uvc_find_device"
);
return
;
}
// select device by index
dev_
=
NULL
;
int
dev_idx
=
0
;
while
(
devs
[
dev_idx
]
!=
NULL
)
{
if
(
dev_idx
==
new_config
.
index
)
{
dev_
=
devs
[
dev_idx
];
}
else
{
uvc_unref_device
(
devs
[
dev_idx
]);
}
dev_idx
++
;
}
if
(
dev_
==
NULL
)
{
ROS_ERROR
(
"Unable to find device at index %d"
,
new_config
.
index
);
return
;
}
uvc_error_t
open_err
=
uvc_open
(
dev_
,
&
devh_
);
if
(
open_err
!=
UVC_SUCCESS
)
{
...
...
@@ -370,10 +389,10 @@ void CameraDriver::OpenCamera(UVCCameraConfig &new_config) {
return
;
}
uvc_error_t
stream_err
=
uvc_start_
iso_
streaming
(
devh_
,
&
ctrl
,
&
CameraDriver
::
ImageCallbackAdapter
,
this
);
uvc_error_t
stream_err
=
uvc_start_streaming
(
devh_
,
&
ctrl
,
&
CameraDriver
::
ImageCallbackAdapter
,
this
,
0
);
if
(
stream_err
!=
UVC_SUCCESS
)
{
uvc_perror
(
stream_err
,
"uvc_start_
iso_
streaming"
);
uvc_perror
(
stream_err
,
"uvc_start_streaming"
);
uvc_close
(
devh_
);
uvc_unref_device
(
dev_
);
return
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment