#include <iostream>
#include <visp3/core/vpImageTools.h>
#ifdef ENABLE_VISP_NAMESPACE
#endif
namespace
{
{
}
for (unsigned int b = 0; b < n; b++) {
}
}
{
"Cannot compute image difference. The two images "
"(%ux%u) and (%ux%u) have not the same size",
}
for (unsigned int b = 0; b < n; b++) {
}
}
}
int main()
{
unsigned int width = 501, height = 447;
vpImage<unsigned char> I1(height, width), I2(height, width), Idiff_regular(height, width), Idiff_sse(height, width);
vpImage<vpRGBa> I1_color(height, width), I2_color(height, width), Idiff_regular_color(height, width),
Idiff_sse_color(height, width);
for (unsigned int i = 0; i < I1.getRows(); i++) {
for (unsigned int j = 0; j < I1.getCols(); j++) {
I1[i][j] = static_cast<unsigned char>(i * I1.getCols() + j);
I1_color[i][j] =
vpRGBa(
static_cast<unsigned char>(i * I1.getCols() + j));
}
}
{
std::cout << "Grayscale:" << std::endl;
double t_regular = 0.0, t_sse = 0.0;
for (unsigned int cpt = 0; cpt < 256; cpt++) {
for (unsigned int i = 0; i < I2.getRows(); i++) {
for (unsigned int j = 0; j < I2.getCols(); j++) {
I2[i][j] = static_cast<unsigned char>(i * I2.getCols() + j + cpt);
}
}
regularImageDifference(I1, I2, Idiff_regular);
if (Idiff_regular != Idiff_sse) {
std::cerr << "Problem with vpImageTools::imageDifference()" << std::endl;
return EXIT_FAILURE;
}
}
std::cout << "(Idiff_regular == Idiff_sse)" << std::endl;
std::cout << "t_regular: " << t_regular << " ms ; mean t_regular: " << t_regular / 256 << " ms" << std::endl;
std::cout << "t_sse: " << t_sse << " ms ; mean t_sse: " << t_sse / 256 << " ms" << std::endl;
std::cout << "speed-up: " << t_regular / t_sse << " times" << std::endl;
}
{
std::cout << "\nColor:" << std::endl;
double t_regular = 0.0, t_sse = 0.0;
for (unsigned int cpt = 0; cpt < 256; cpt++) {
for (unsigned int i = 0; i < I2.getRows(); i++) {
for (unsigned int j = 0; j < I2.getCols(); j++) {
I2_color[i][j] =
vpRGBa(
static_cast<unsigned char>(i * I2.getCols() + j + cpt));
}
}
regularImageDifference(I1_color, I2_color, Idiff_regular_color);
if (Idiff_regular_color != Idiff_sse_color) {
std::cerr << "Problem with vpImageTools::imageDifference()" << std::endl;
return EXIT_FAILURE;
}
}
std::cout << "(Idiff_regular_color == Idiff_sse_color)" << std::endl;
std::cout << "t_regular: " << t_regular << " ms ; mean t_regular: " << t_regular / 256 << " ms" << std::endl;
std::cout << "t_sse: " << t_sse << " ms ; mean t_sse: " << t_sse / 256 << " ms" << std::endl;
std::cout << "speed-up: " << t_regular / t_sse << " times" << std::endl;
}
{
std::cout << "Test vpRGBa" << std::endl;
if (rgba_1 == rgba_2) {
std::cout << "Test ok: same rgba" << std::endl;
}
else {
std::cerr << "Error in rgba operator==" << std::endl;
return EXIT_FAILURE;
}
if (rgba_1 != rgba_2) {
std::cerr << "Error in rgba operator!=" << std::endl;
return EXIT_FAILURE;
}
{
if (rgba_1 == (rgba_2 + rgba_3)) {
std::cerr << "Error in rgba operator==" << std::endl;
return EXIT_FAILURE;
}
if (rgba_1 != (rgba_2 + rgba_3)) {
std::cerr << "Test ok: R value differ" << std::endl;
}
}
{
if (rgba_1 == (rgba_2 + rgba_3)) {
std::cerr << "Error in rgba operator==" << std::endl;
return EXIT_FAILURE;
}
if (rgba_1 != (rgba_2 + rgba_3)) {
std::cerr << "Test ok: G value differ" << std::endl;
}
}
{
if (rgba_1 == (rgba_2 + rgba_3)) {
std::cerr << "Error in rgba operator==" << std::endl;
return EXIT_FAILURE;
}
if (rgba_1 != (rgba_2 + rgba_3)) {
std::cerr << "Test ok: B value differ" << std::endl;
}
}
}
{
std::cout << "Test vpRGBf" << std::endl;
vpRGBf rgbf_1(10.f, 20.f, 30.f);
vpRGBf rgbf_2(10.f, 20.f, 30.f);
if (rgbf_1 == rgbf_2) {
std::cout << "Test ok: same rgbf" << std::endl;
}
else {
std::cerr << "Error in rgbf operator==" << std::endl;
return EXIT_FAILURE;
}
if (rgbf_1 != rgbf_2) {
std::cerr << "Error in rgbf operator!=" << std::endl;
return EXIT_FAILURE;
}
{
vpRGBf rgbf_3(1e-6f, 0.f, 0.f);
if (rgbf_1 == (rgbf_2 + rgbf_3)) {
std::cerr << "Rf Error in rgbf operator==" << std::endl;
return EXIT_FAILURE;
}
if (rgbf_1 != (rgbf_2 + rgbf_3)) {
std::cerr << "Test ok: Rf value differ" << std::endl;
}
}
{
vpRGBf rgbf_3(0.f, 1e-6f, 0.f);
if (rgbf_1 == (rgbf_2 + rgbf_3)) {
std::cerr << "Gf Error in rgbf operator==" << std::endl;
return EXIT_FAILURE;
}
if (rgbf_1 != (rgbf_2 + rgbf_3)) {
std::cerr << "Test ok: Gf value differ" << std::endl;
}
}
{
vpRGBf rgbf_3(0.f, 0.f, 1e-6f);
if (rgbf_1 == (rgbf_2 + rgbf_3)) {
std::cerr << "Bf Error in rgbf operator==" << std::endl;
return EXIT_FAILURE;
}
if (rgbf_1 != (rgbf_2 + rgbf_3)) {
std::cerr << "Test ok: Bf value differ" << std::endl;
}
}
}
std::cout << "Test succeed" << std::endl;
return EXIT_SUCCESS;
}
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
unsigned int getWidth() const
void resize(unsigned int h, unsigned int w)
resize the image : Image initialization
Type * bitmap
points toward the bitmap
unsigned int getHeight() const
static Type maximum(const Type &a, const Type &b)
static Type minimum(const Type &a, const Type &b)
unsigned char B
Blue component.
unsigned char R
Red component.
unsigned char G
Green component.
unsigned char A
Additionnal component.
VISP_EXPORT double measureTimeMs()