Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
firewire_camera
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
Model registry
Operate
Environments
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
labrobotica
drivers
firewire_camera
Commits
5f1bf6e9
Commit
5f1bf6e9
authored
10 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added a function to get the bayer pattern of the sensor.
Added a function to get the image data with a provied pointer.
parent
34c208a3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/examples/firewire_camera_cont.cpp
+3
-1
3 additions, 1 deletion
src/examples/firewire_camera_cont.cpp
src/firewirecamera.cpp
+72
-0
72 additions, 0 deletions
src/firewirecamera.cpp
src/firewirecamera.h
+10
-0
10 additions, 0 deletions
src/firewirecamera.h
with
85 additions
and
1 deletion
src/examples/firewire_camera_cont.cpp
+
3
−
1
View file @
5f1bf6e9
...
...
@@ -20,7 +20,7 @@ int main(int argc, char *argv[])
unsigned
int
left_off
,
top_off
;
depths_t
depth
;
codings_t
coding
;
int
i
=
0
;
int
i
=
0
,
bayer_pattern
;
std
::
list
<
std
::
string
>
event_list
;
float
framerate
=
30
;
char
*
image
=
NULL
;
...
...
@@ -47,6 +47,8 @@ int main(int argc, char *argv[])
camera1
->
get_config
(
&
left_off
,
&
top_off
,
&
width
,
&
height
,
&
framerate
,
&
depth
,
&
coding
);
camera1
->
set_config
(
&
left_off
,
&
top_off
,
&
width
,
&
height
,
&
framerate
,
depth
,
coding
);
std
::
cout
<<
framerate
<<
std
::
endl
;
camera1
->
get_bayer_pattern
((
dc1394color_filter_t
*
)
&
bayer_pattern
);
std
::
cout
<<
bayer_pattern
<<
std
::
endl
;
/* start continuous acquisition */
camera1
->
start
();
for
(
i
=
0
;
i
<
num_frames
;
i
++
)
...
...
This diff is collapsed.
Click to expand it.
src/firewirecamera.cpp
+
72
−
0
View file @
5f1bf6e9
...
...
@@ -9,6 +9,7 @@
#include
<math.h>
#include
<sstream>
#include
<iostream>
#include
<dc1394/register.h>
CFirewireCamera
::
CFirewireCamera
(
dc1394_t
*
firewire
,
uint64_t
camera_id
)
{
...
...
@@ -1545,6 +1546,64 @@ void CFirewireCamera::get_image(char **image)
}
}
void
CFirewireCamera
::
get_image_shared
(
char
*
image
)
{
int
depth
;
dc1394error_t
error
;
dc1394video_frame_t
*
frame
;
if
(
image
!=
NULL
)
{
DEBUG_INFO
(
"Invalid image buffer.
\n
"
);
/* handle error */
throw
CFirewireCameraException
(
_HERE_
,
"Invalid image buffer. Please provide an unallocated memory buffer."
);
}
DEBUG_INFO
(
"Capturing a new image ... "
);
if
(
this
->
one_shot_mode
==
DC1394_ON
)
{
/* set the one shot mode */
DEBUG_INFO
(
"Setting the one shot mode ... "
);
error
=
dc1394_video_set_one_shot
(
this
->
camera_handle
,
DC1394_ON
);
if
(
error
!=
DC1394_SUCCESS
)
{
DEBUG_INFO
(
"failed
\n
"
);
/* handle the error */
throw
CFirewireInternalException
(
_HERE_
,
error
);
}
DEBUG_INFO
(
"ok
\n
"
);
DEBUG_INFO
(
"Dequeuing a DMA buffer ... "
);
error
=
dc1394_capture_dequeue
(
this
->
camera_handle
,
DC1394_CAPTURE_POLICY_WAIT
,
&
frame
);
if
(
error
!=
DC1394_SUCCESS
)
{
DEBUG_INFO
(
"failed
\n
"
);
/* handle error */
throw
CFirewireInternalException
(
_HERE_
,
error
);
}
depth
=
(
int
)
ceil
((
float
)
this
->
depth
/
8.0
);
if
(
this
->
frame_buffer
!=
NULL
)
delete
[]
this
->
frame_buffer
;
this
->
frame_buffer
=
new
char
[
this
->
width
*
this
->
height
*
depth
];
memcpy
(
image
,
frame
->
image
,
this
->
width
*
this
->
height
*
depth
);
memcpy
(
this
->
frame_buffer
,
frame
->
image
,
this
->
width
*
this
->
height
*
depth
);
DEBUG_INFO
(
"ok
\n
"
);
DEBUG_INFO
(
"Freeing the DMA buffer ... "
);
error
=
dc1394_capture_enqueue
(
this
->
camera_handle
,
frame
);
if
(
error
!=
DC1394_SUCCESS
)
{
DEBUG_INFO
(
"failed
\n
"
);
/* handle error */
throw
CFirewireInternalException
(
_HERE_
,
error
);
}
DEBUG_INFO
(
"ok
\n
"
);
}
else
{
this
->
image_access
.
enter
();
depth
=
(
int
)
ceil
((
float
)
this
->
depth
/
8.0
);
memcpy
(
image
,
this
->
frame_buffer
,
this
->
width
*
this
->
height
*
depth
);
this
->
image_access
.
exit
();
}
}
#ifdef HAVE_OPENCV_H
void
CFirewireCamera
::
get_image
(
cv
::
Mat
&
image
)
{
...
...
@@ -1661,6 +1720,19 @@ void CFirewireCamera::get_new_frame_event_id(std::string& event_id)
event_id
=
this
->
new_frame_event_id
;
}
void
CFirewireCamera
::
get_bayer_pattern
(
dc1394color_filter_t
*
pattern
)
{
dc1394error_t
error
;
error
=
dc1394_format7_get_color_filter
(
this
->
camera_handle
,
this
->
mode
,
pattern
);
if
(
error
!=
DC1394_SUCCESS
)
{
DEBUG_INFO
(
"failed
\n
"
);
/* handle error */
throw
CFirewireInternalException
(
_HERE_
,
error
);
}
}
void
CFirewireCamera
::
set_num_DMA_buffers
(
int
num
)
{
dc1394error_t
error
;
...
...
This diff is collapsed.
Click to expand it.
src/firewirecamera.h
+
10
−
0
View file @
5f1bf6e9
...
...
@@ -1059,6 +1059,11 @@ class CFirewireCamera
*
*/
void
get_image
(
char
**
image
);
/**
* \brief
*
*/
void
get_image_shared
(
char
*
image
);
#ifdef HAVE_OPENCV_H
/**
* As get_image() but returns an OpenCV2.0-c++-like image
...
...
@@ -1164,6 +1169,11 @@ class CFirewireCamera
*
*/
void
get_new_frame_event_id
(
std
::
string
&
event_id
);
/**
* \brief
*
*/
void
get_bayer_pattern
(
dc1394color_filter_t
*
pattern
);
/**
* \brief Function to show the general information of the associated camera
*
...
...
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