Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
test1394TwoGrabber.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Firewire cameras video capture.
32
*/
33
39
40
#include <visp3/core/vpConfig.h>
41
#include <visp3/core/vpDebug.h>
42
43
#include <iostream>
44
#include <string>
45
46
#ifdef ENABLE_VISP_NAMESPACE
47
using namespace
VISP_NAMESPACE_NAME
;
48
#endif
49
50
#if defined(VISP_HAVE_DC1394)
51
52
#include <visp3/core/vpIoTools.h>
53
#include <visp3/io/vpImageIo.h>
54
#include <visp3/sensor/vp1394TwoGrabber.h>
55
56
int
main()
57
{
58
try
{
59
std::cout <<
"IEEE1394 test in progress..."
<< std::endl;
60
61
// Get the user name
62
std::string username;
63
vpIoTools::getUserName
(username);
64
std::string outputpath =
"/tmp/"
+ username;
65
vpIoTools::makeDirectory
(outputpath);
66
67
// Creation of an empty image container
68
vpImage<unsigned char>
I;
69
70
// Creation of a framegrabber
71
vp1394TwoGrabber
g;
72
uint64_t guid;
73
74
// Get the number of cameras connected on the bus
75
unsigned
int
ncameras;
// Number of cameras on the bus
76
ncameras = g.
getNumCameras
();
77
for
(
unsigned
int
i = 0;
i
< ncameras;
i
++) {
78
g.
setCamera
(i);
79
g.
getGuid
(guid);
80
std::cout <<
"Detected camera with GUID 0x"
<< std::hex << guid << std::endl;
81
}
82
// If more than one camera connected, use the last one
83
if
(ncameras > 1) {
84
g.
setCamera
(ncameras - 1);
85
g.
getGuid
(guid);
86
std::cout <<
"Use camera with GUID 0x"
<< std::hex << guid << std::endl;
87
g.
setCamera
(0);
// to be sure that the setCamera() in the next line with
88
// guid as parameter works
89
g.
setCamera
(guid);
90
}
91
92
for
(
int
i = 0;
i
< 10;
i
++)
93
g.
acquire
(I);
94
g.
close
();
95
std::string
filename
= outputpath +
"/imagetest1.pgm"
;
96
std::cout <<
"Write image: "
<<
filename
<< std::endl;
97
vpImageIo::write
(I, filename);
98
99
std::cout <<
"New connection..."
<< std::endl;
100
g.
open
(I);
101
g.
close
();
102
103
std::cout <<
"New connection..."
<< std::endl;
104
g.
open
(I);
105
// g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_800x600_YUV422);
106
g.
acquire
(I);
107
g.
close
();
108
filename
= outputpath +
"/imagetest2.pgm"
;
109
std::cout <<
"Write image: "
<<
filename
<< std::endl;
110
vpImageIo::write
(I, filename);
111
}
112
catch
(...) {
113
vpCERROR
<<
"Failure: exit"
<< std::endl;
114
}
115
}
116
#else
117
int
main()
118
{
119
vpTRACE
(
"Ieee 1394 grabber capabilities are not available..."
);
120
vpTRACE
(
"You should install libdc1394-2 to use this binary."
);
121
}
122
123
#endif
vp1394TwoGrabber
Class for firewire ieee1394 video devices using libdc1394-2.x api.
Definition
vp1394TwoGrabber.h:185
vp1394TwoGrabber::acquire
void acquire(vpImage< unsigned char > &I)
Definition
vp1394TwoGrabber.cpp:2559
vp1394TwoGrabber::setCamera
void setCamera(uint64_t camera)
Definition
vp1394TwoGrabber.cpp:293
vp1394TwoGrabber::close
void close()
Definition
vp1394TwoGrabber.cpp:1482
vp1394TwoGrabber::getGuid
uint64_t getGuid()
Definition
vp1394TwoGrabber.cpp:3382
vp1394TwoGrabber::getNumCameras
void getNumCameras(unsigned int &ncameras) const
Definition
vp1394TwoGrabber.cpp:387
vp1394TwoGrabber::open
void open(vpImage< unsigned char > &I)
Definition
vp1394TwoGrabber.cpp:2114
vpImageIo::write
static void write(const vpImage< unsigned char > &I, const std::string &filename, int backend=IO_DEFAULT_BACKEND)
Definition
vpImageIo.cpp:336
vpImage
Definition of the vpImage class member functions.
Definition
vpImage.h:131
vpIoTools::getUserName
static std::string getUserName()
Definition
vpIoTools.cpp:302
vpIoTools::makeDirectory
static void makeDirectory(const std::string &dirname)
Definition
vpIoTools.cpp:567
vpCERROR
#define vpCERROR
Definition
vpDebug.h:393
vpTRACE
#define vpTRACE
Definition
vpDebug.h:450
VISP_NAMESPACE_NAME
Definition
vpEigenConversion.h:44
gen_java.filename
filename
Definition
gen_java.py:1294
yolo-centering-task-afma6.i
i
Definition
yolo-centering-task-afma6.py:329
modules
sensor
test
framegrabber
test1394TwoGrabber.cpp
Generated by
1.17.0