Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multicam driver #30

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2a0e80e
Makefile target for debug build
Jan 9, 2016
e9797e4
extend .gitignore for linux-binaries and NetBeans
Jan 21, 2016
5c74d60
Merge remote-tracking branch 'upstream/master'
s-light Mar 1, 2017
198ac02
Merge branch 'master' of mkalten/reacTIVision
s-light Mar 2, 2017
5f665d3
Merge branch 'master' of https://github.com/mkalten/reacTIVision
s-light May 16, 2017
28756f6
Merge branch 'master' of https://github.com/mkalten/reacTIVision
s-light Jun 8, 2017
0fdad4d
Merge branch 'master' of https://github.com/mkalten/reacTIVision
s-light Jun 9, 2017
658c02c
Merge branch 'master' of https://github.com/mkalten/reacTIVision
s-light Jun 13, 2017
408df47
Merge branch 'master' of https://github.com/mkalten/reacTIVision
s-light Sep 25, 2017
7740fb1
added some more descriptive error messages for camera file reading
s-light Sep 25, 2017
da443c8
extend SportVideo makefile
s-light Sep 29, 2017
70ab90f
added debug messages
s-light Oct 11, 2017
eba997e
CameraTool.cpp code-syntax changes
s-light Oct 11, 2017
615dfee
camera.xml: forced saving for frame attributes
s-light Oct 13, 2017
68e9da8
updated gitignore
s-light Oct 13, 2017
4e2b16c
added frame_x and frame_y attributs + fixed setCameraConfig
s-light Oct 13, 2017
0e6eaca
CameraTool - split out `whereIsConfig`
s-light Oct 13, 2017
180ebdd
CameraTool - split out `whereIsConfig`
s-light Oct 13, 2017
e9e6f5c
Merge branch 'multicam_driver' of github.com:s-light/reacTIVision int…
s-light Oct 13, 2017
3bfbf51
some code formating for easier reading + more debug output
s-light Oct 16, 2017
7fbc7bc
started adding rgb8 support to V4L2 cam
s-light Oct 16, 2017
d9def4f
adding rgb8 support to V4L2 cam - working :-)
s-light Oct 16, 2017
6de0be8
preparations & clean up in camera configuration
s-light Oct 16, 2017
3617f36
prepared multicam
s-light Oct 21, 2017
b1fbb04
enabled multicam things
s-light Oct 21, 2017
aa5eb0e
added debug messages + commented child movement--> it crashes
s-light Oct 21, 2017
d12136b
fixed positioning, cropping in CameraEngine seems buggy
s-light Oct 25, 2017
ba11e0e
commented getCameraConfigs
s-light Oct 25, 2017
8c4eeff
prepare listing fo Multicam configuraitons
s-light Oct 25, 2017
427c21c
fix crash at camera selection
s-light Oct 25, 2017
d9aef64
re enabled multicam listing in camera configuration gui
s-light Oct 25, 2017
bdf7a08
fix pixelformat debugmessage
s-light Oct 25, 2017
546e280
enchance multicam listing in gui
s-light Oct 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
xcuserdata

build

Debug

Release

Frameworks

*.pbxuser

*.mode1v3

project.xcworkspace

*.sdf

*.suo

*.exe

*.opensdf

.DS_Store

*.o
*.h.gch

linux/reacTIVision

ext/portvideo/linux/SportVideo

nbproject/
74 changes: 47 additions & 27 deletions common/CalibrationGrid.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* CalibrationGrid.cpp - part of the reacTIVision project
Copyright (c) 2006 Marcos Alonso <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

Any person wishing to distribute modifications to the Software is
requested to send the modifications to the original developer so that
they can be incorporated into the canonical version.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Expand All @@ -30,7 +30,7 @@
GridPoint CalibrationGrid::Get(int x, int y)
{
if( x>=0 && x<width && y>=0 && y<height ) return points_[y*width+x];

GridPoint npoint;
npoint.x = 0;
npoint.y = 0;
Expand All @@ -54,7 +54,7 @@ bool CalibrationGrid::IsEmpty()
if (points_[i].x != 0) return false;
if (points_[i].y != 0) return false;
}

return true;
}

Expand All @@ -76,6 +76,16 @@ void CalibrationGrid::Load(const char* filename)
file >> points_[i].y;
}
file.close();
#ifdef DEBUG
std::cout << "CalibrationGrid with " << points_.size() << " points "
<< "loaded ";
if (file.fail()) {
std::cout << "with errors";
} else {
std::cout << "successful";
}
std::cout << " from file '" << filename << "'" << std::endl;
#endif
}

void CalibrationGrid::Store(const char* filename)
Expand All @@ -86,91 +96,101 @@ void CalibrationGrid::Store(const char* filename)
file << points_[i].x << " " << points_[i].y << "\n";
}
file.close();
#ifdef DEBUG
std::cout << "CalibrationGrid with " << points_.size() << " points "
<< "saved ";
if (file.fail()) {
std::cout << "with errors";
} else {
std::cout << "successful";
}
std::cout << " to file '" << filename << "'" << std::endl;
#endif
}

GridPoint CalibrationGrid::GetInterpolated( float x, float y )
{
GridPoint point;

if( x>=width ) return GetInterpolatedY(width,y);
if( y>=height ) return GetInterpolatedX(x,height);

// x
int x_floor = (int)floor(x);
float x_offset = x - x_floor;

GridPoint x1 = GetInterpolatedY(x_floor,y);
GridPoint x2 = GetInterpolatedY(x_floor+1,y);
point.x = (x1.x * (1-x_offset)) + (x2.x * x_offset);

// y
int y_floor = (int)floor(y);
float y_offset = y - y_floor;

GridPoint y1 = GetInterpolatedX(x,y_floor);
GridPoint y2 = GetInterpolatedX(x,y_floor+1);
point.y = (y1.y * (1-y_offset)) + (y2.y * y_offset);

return point;
}

GridPoint CalibrationGrid::GetInterpolatedX( float x, int y )
{
int x_floor = (int)floor(x);
float x_offset = x - x_floor;

GridPoint v1;
if( x_floor<=0 ) v1 = points_[ (y*width) + x_floor ];
else v1 = points_[ (y*width) + x_floor-1 ];

GridPoint v2 = points_[ (y*width) + x_floor ];

GridPoint v3 = points_[ (y*width) + x_floor+1 ];

GridPoint v4;
if( x_floor>=(width-2) ) v4 = points_[ (y*width) + x_floor+1 ];
else v4 = points_[ (y*width) + x_floor+2 ];

GridPoint point;
point.x = catmullRomSpline( x_offset, v1.x, v2.x, v3.x, v4.x );
point.y = catmullRomSpline( x_offset, v1.y, v2.y, v3.y, v4.y );

return point;
}

GridPoint CalibrationGrid::GetInterpolatedY( int x, float y )
{
int y_floor = (int)floor(y);
float y_offset = y - y_floor;

GridPoint v1;
if( y_floor<=0 ) v1 = points_[ (y_floor*width) + x ];
else v1 = points_[ ((y_floor-1) * width) + x ];

GridPoint v2 = points_[ (y_floor * width) + x ];

GridPoint v3 = points_[ ((y_floor+1) * width) + x ];

GridPoint v4;
if( y_floor>=(height-2) ) v4 = points_[ ((y_floor+1) * width) + x ];
else v4 = points_[ ((y_floor+2) * width) + x ];


GridPoint point;
point.x = catmullRomSpline( y_offset, v1.x, v2.x, v3.x, v4.x );
point.y = catmullRomSpline( y_offset, v1.y, v2.y, v3.y, v4.y );

return point;
}

inline double CalibrationGrid::catmullRomSpline(double x,double v1,double v2,double v3,double v4)
{
double c1,c2,c3,c4;

c1 = 1.0*v2;
c2 = -0.5*v1 + 0.5*v3;
c3 = 1.0*v1 + -2.5*v2 + 2.0*v3 + -0.5*v4;
c4 = -0.5*v1 + 1.5*v2 + -1.5*v3 + 0.5*v4;

return (((c4*x + c3)*x +c2)*x + c1);
}
100 changes: 89 additions & 11 deletions ext/portvideo/common/CameraEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,98 @@
#include "CameraEngine.h"
#include "CameraTool.h"

const char* dstr[] = { "default","dc1394","ps3eye","raspi","uvccam","","","","","","file","folder"};

const char* fstr[] = { "unknown", "mono8", "mono16", "rgb8", "rgb16", "mono16s", "rgb16s", "raw8", "raw16", "rgba", "yuyv", "uyvy", "yuv411", "yuv444", "yuv420p", "yuv410p", "yvyu", "yuv211", "", "", "jpeg", "mjpeg", "mpeg", "mpeg2", "mpeg4", "h263", "h264", "", "", "", "dvpal", "dvntsc" };
const char* dstr[] = {
"default",
"dc1394",
"ps3eye",
"raspi",
"uvccam",
"",
"",
"",
"",
"",
"file",
"folder",
"multicam"
};

const char* fstr[] = {
"unknown",
"mono8",
"mono16",
"rgb8",
"rgb16",
"mono16s",
"rgb16s",
"raw8",
"raw16",
"rgba",

"yuyv",
"uyvy",
"yuv411",
"yuv444",
"yuv420p",
"yuv410p",
"yvyu",
"yuv211",
"",
"",

"jpeg",
"mjpeg",
"mpeg",
"mpeg2",
"mpeg4",
"h263",
"h264",
"",
"",
"",

"dvpal",
"dvntsc"
};


void CameraEngine::printInfo() {
printf("camera: %s\n",cfg->name);
printf("driver: %s\n",dstr[cfg->driver]);
printf("codec: %s\n",fstr[cfg->cam_format]);
printf("camera: %s\n", cfg->name);
printf("driver: %s\n", dstr[cfg->driver]);
printf("codec: %s\n", fstr[cfg->cam_format]);
if (cfg->frame_mode<0) {
if (cfg->cam_fps==(int)cfg->cam_fps) printf("format: %dx%d, %dfps\n",cfg->frame_width,cfg->frame_height,(int)cfg->cam_fps);
else printf("format: %dx%d, %.1ffps\n",cfg->frame_width,cfg->frame_height,cfg->cam_fps);
// print fps as int or float
if (cfg->cam_fps==(int)cfg->cam_fps) {
printf(
"format: %dx%d, %dfps\n",
cfg->frame_width,
cfg->frame_height,
(int)cfg->cam_fps
);
} else {
printf(
"format: %dx%d, %.1ffps\n",
cfg->frame_width,
cfg->frame_height,
cfg->cam_fps
);
}
} else {
printf(
"format7_%d: %dx%d\n",
cfg->frame_mode,
cfg->frame_width,
cfg->frame_height
);
}
// if frame_x or frame_y != 0 print this information
if ((cfg->frame_x != 0) || cfg->frame_y != 0) {
printf(
"x: %d y:%d\n",
cfg->frame_x,
cfg->frame_y
);
}
else printf("format7_%d: %dx%d\n",cfg->frame_mode,cfg->frame_width,cfg->frame_height);
}

void CameraEngine::setMinMaxConfig(CameraConfig *cam_cfg, std::vector<CameraConfig> cfg_list) {
Expand Down Expand Up @@ -150,7 +228,7 @@ void CameraEngine::showInterface(UserInterface *uiface) {
//int settingValue = getCameraSetting(currentCameraSetting);
//int maxValue = getMaxCameraSetting(currentCameraSetting);
//int minValue = getMinCameraSetting(currentCameraSetting);

const char *settingText = NULL;
switch (currentCameraSetting) {
case BRIGHTNESS: settingText = "Brightness"; break;
Expand Down Expand Up @@ -415,7 +493,7 @@ void CameraEngine::grayw2rgb(int width, int height, unsigned char *src, unsigned
dest_pixel = (unsigned char)(src_pixel/4);
*dest++ = dest_pixel;
*dest++ = dest_pixel;
*dest++ = dest_pixel;
*dest++ = dest_pixel;
}
}

Expand Down
Loading