From 9d7c822e7601744b5c40dd93d24422089b11695f Mon Sep 17 00:00:00 2001 From: Victor Erukhimov Date: Sat, 22 Feb 2020 18:25:48 +0300 Subject: [PATCH] updated rois for the new cup image --- book_samples/filter/filterImageROI.c | 27 ++++++++++++++------- book_samples/filter/filterImageROIvxu.c | 31 ++++++++++++++++--------- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/book_samples/filter/filterImageROI.c b/book_samples/filter/filterImageROI.c index 5c987ce..2f06573 100644 --- a/book_samples/filter/filterImageROI.c +++ b/book_samples/filter/filterImageROI.c @@ -59,19 +59,26 @@ vx_graph makeFilterGraph(vx_context context, vx_image input, return graph; } -void main(int argc, char **argv) +int main(int argc, char **argv) { + if (argc != 3) + { + printf("Filter an image\n" + "%s \n", (char *)argv[0]); + return(1); + } + struct read_image_attributes attr; vx_context context = vxCreateContext(); - vx_image image = createImageFromFile(context, "cup.ppm", &attr); + vx_image image = createImageFromFile(context, (const char*) argv[1], &attr); vx_rectangle_t rect; - rect.start_x = 48; - rect.start_y = 98; - rect.end_x = 258; - rect.end_y = 202; - int width = rect.end_x - rect.start_x; - int height = rect.end_y - rect.start_y; + rect.start_x = 204; + rect.start_y = 179; + int width = 178; + int height = 190; + rect.end_x = rect.start_x + width; + rect.end_y = rect.start_y + height; vx_image output = vxCreateImage(context, width, height, VX_DF_IMAGE_RGB); vx_graph graph = makeFilterGraph(context, image, &rect, output); @@ -79,7 +86,9 @@ void main(int argc, char **argv) printf("Could not create input image\n"); else if (vxProcessGraph(graph)) printf("Error processing graph\n"); - else if (writeImage(output, "cup_scharr_roi.ppm")) + else if (writeImage(output, (const char*)argv[2])) printf("Problem writing the output image\n"); vxReleaseContext(&context); + + return(0); } diff --git a/book_samples/filter/filterImageROIvxu.c b/book_samples/filter/filterImageROIvxu.c index 29dea75..e0068fb 100644 --- a/book_samples/filter/filterImageROIvxu.c +++ b/book_samples/filter/filterImageROIvxu.c @@ -9,9 +9,14 @@ Read and write an image. #include "readImage.h" #include "writeImage.h" -void main(int argc, char **argv) +int main(int argc, char **argv) { - printf("Started\n"); + if (argc != 3) + { + printf("Filter an image\n" + "%s \n", (char *)argv[0]); + return(1); + } struct read_image_attributes attr; vx_context context = vxCreateContext(); @@ -19,18 +24,20 @@ void main(int argc, char **argv) border_mode.mode = VX_BORDER_REPLICATE; vxSetContextAttribute(context, VX_CONTEXT_IMMEDIATE_BORDER, &border_mode, sizeof(border_mode)); - vx_image input = createImageFromFile(context, "cup.ppm", &attr); + vx_image input = createImageFromFile(context, (const char*)argv[1], &attr); printf("input image created\n"); - if(vxGetStatus(input) != VX_SUCCESS) + if(vxGetStatus((vx_reference)input) != VX_SUCCESS) { - printf("Status error: %d", vxGetStatus(input)); + printf("Status error: %d", vxGetStatus((vx_reference)input)); } vx_rectangle_t rect; - rect.start_x = 48; - rect.start_y = 98; - rect.end_x = 258; - rect.end_y = 202; + rect.start_x = 204; + rect.start_y = 179; + int rect_width = 178; + int rect_height = 190; + rect.end_x = rect.start_x + rect_width; + rect.end_y = rect.start_y + rect_height; vx_image roi = vxCreateImageFromROI(input, &rect); int width = rect.end_x - rect.start_x; @@ -49,7 +56,7 @@ void main(int argc, char **argv) /* create a threshold object */ vx_threshold threshold = vxCreateThresholdForImage(context, VX_THRESHOLD_TYPE_RANGE, VX_DF_IMAGE_U8, VX_DF_IMAGE_U8); - if(vxGetStatus(threshold) != VX_SUCCESS) + if(vxGetStatus((vx_reference)threshold) != VX_SUCCESS) { printf("Threshold creation failed\n"); } @@ -81,10 +88,12 @@ void main(int argc, char **argv) vxReleaseImage(&edges_inv); vxReleaseThreshold(&threshold); - if(writeImage(input, "cup_roi.ppm")) + if(writeImage(input, (const char*)argv[2])) printf("Problem writing the output image\n"); vxReleaseImage(&roi); vxReleaseImage(&input); vxReleaseContext(&context); + + return(0); }