Commit ae39d71b authored by Doris Liu's avatar Doris Liu
Browse files

Move tests from camera to gallery2

Change-Id: If9143fff7d22295a5ad3bb01c4b860d07c3ee1c9
parent 066f0517
local_target_dir := $(TARGET_OUT_DATA)/local/tmp
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../../jni_mosaic/feature_mos/src \
$(LOCAL_PATH)/../../jni_mosaic/feature_stab/src \
$(LOCAL_PATH)/../../jni_mosaic/feature_stab/db_vlvm
LOCAL_CFLAGS := -O3 -DNDEBUG
LOCAL_SRC_FILES := benchmark.cpp
LOCAL_SHARED_LIBRARIES := libjni_mosaic libGLESv2 libEGL
LOCAL_MODULE_TAGS := tests
LOCAL_LDFLAGS := -llog -lGLESv2
LOCAL_MODULE := panorama_bench
LOCAL_MODULE_PATH := $(local_target_dir)
include $(BUILD_EXECUTABLE)
How to run and verify the benchmark:
1) adb push input /data/panorama_input
2) adb shell panorama_bench /data/panorama_input/test /data/panorama.ppm
Sample output:
38 frames loaded
Iteration 0: 1454x330 moasic created: 4.33 seconds (2.05 + 2.28)
Iteration 1: 1454x330 moasic created: 4.26 seconds (1.83 + 2.44)
Iteration 2: 1454x330 moasic created: 5.57 seconds (2.73 + 2.84)
Iteration 3: 1454x330 moasic created: 5.15 seconds (2.33 + 2.82)
Iteration 4: 1454x330 moasic created: 6.22 seconds (2.05 + 4.16)
Iteration 5: 1454x330 moasic created: 6.31 seconds (2.16 + 4.15)
Iteration 6: 1454x330 moasic created: 5.04 seconds (2.03 + 3.01)
Iteration 7: 1454x330 moasic created: 6.30 seconds (3.47 + 2.83)
Iteration 8: 1454x330 moasic created: 6.57 seconds (1.83 + 4.73)
Iteration 9: 1454x330 moasic created: 6.27 seconds (2.28 + 4.00)
Total elapsed time: 56.02 seconds
The first number in the parenthesis is the time to align the frames; the second
number is the time to stitch them.
The total elapsed time is the interesting number for benchmarking.
3) adb pull /data/panorama.ppm .
4) diff panorama.ppm output/golden.ppm
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "mosaic/Mosaic.h"
#include "mosaic/ImageUtils.h"
#define MAX_FRAMES 200
#define KERNEL_ITERATIONS 10
const int blendingType = Blend::BLEND_TYPE_HORZ;
const int stripType = Blend::STRIP_TYPE_WIDE;
ImageType yvuFrames[MAX_FRAMES];
int loadImages(const char* basename, int &width, int &height)
{
char filename[512];
struct stat filestat;
int i;
for (i = 0; i < MAX_FRAMES; i++) {
sprintf(filename, "%s_%03d.ppm", basename, i + 1);
if (stat(filename, &filestat) != 0) break;
ImageType rgbFrame = ImageUtils::readBinaryPPM(filename, width, height);
yvuFrames[i] = ImageUtils::allocateImage(width, height,
ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
ImageUtils::rgb2yvu(yvuFrames[i], rgbFrame, width, height);
ImageUtils::freeImage(rgbFrame);
}
return i;
}
int main(int argc, char **argv)
{
struct timespec t1, t2, t3;
int width, height;
float totalElapsedTime = 0;
const char *basename;
const char *filename;
if (argc != 3) {
printf("Usage: %s input_dir output_filename\n", argv[0]);
return 0;
} else {
basename = argv[1];
filename = argv[2];
}
// Load the images outside the computational kernel
int totalFrames = loadImages(basename, width, height);
if (totalFrames == 0) {
printf("Image files not found. Make sure %s exists.\n",
basename);
return 1;
}
printf("%d frames loaded\n", totalFrames);
// Interesting stuff is here
for (int iteration = 0; iteration < KERNEL_ITERATIONS; iteration++) {
Mosaic mosaic;
mosaic.initialize(blendingType, stripType, width, height, -1, false, 0);
clock_gettime(CLOCK_MONOTONIC, &t1);
for (int i = 0; i < totalFrames; i++) {
mosaic.addFrame(yvuFrames[i]);
}
clock_gettime(CLOCK_MONOTONIC, &t2);
float progress = 0.0;
bool cancelComputation = false;
mosaic.createMosaic(progress, cancelComputation);
int mosaicWidth, mosaicHeight;
ImageType resultYVU = mosaic.getMosaic(mosaicWidth, mosaicHeight);
ImageType imageRGB = ImageUtils::allocateImage(
mosaicWidth, mosaicHeight, ImageUtils::IMAGE_TYPE_NUM_CHANNELS);
clock_gettime(CLOCK_MONOTONIC, &t3);
float elapsedTime =
(t3.tv_sec - t1.tv_sec) + (t3.tv_nsec - t1.tv_nsec)/1e9;
float addImageTime =
(t2.tv_sec - t1.tv_sec) + (t2.tv_nsec - t1.tv_nsec)/1e9;
float stitchImageTime =
(t3.tv_sec - t2.tv_sec) + (t3.tv_nsec - t2.tv_nsec)/1e9;
totalElapsedTime += elapsedTime;
printf("Iteration %d: %dx%d moasic created: "
"%.2f seconds (%.2f + %.2f)\n",
iteration, mosaicWidth, mosaicHeight,
elapsedTime, addImageTime, stitchImageTime);
// Write the output only once for correctness check
if (iteration == 0) {
ImageUtils::yvu2rgb(imageRGB, resultYVU, mosaicWidth,
mosaicHeight);
ImageUtils::writeBinaryPPM(imageRGB, filename, mosaicWidth,
mosaicHeight);
}
}
printf("Total elapsed time: %.2f seconds\n", totalElapsedTime);
return 0;
}
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment