Skip to content

Commit

Permalink
Merge changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cwlacewe committed May 6, 2024
1 parent caefd9b commit fb6070e
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 136 deletions.
1 change: 1 addition & 0 deletions docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ RUN rm -rf /dependencies /usr/local/share/doc /usr/local/share/man && \
mkdir -p /opt/dist/usr/include/x86_64-linux-gnu && \
cp -rp /usr/include/x86_64-linux-gnu /opt/dist/usr/include/x86_64-linux-gnu


############################################################
# FINAL IMAGE
FROM base
Expand Down
1 change: 1 addition & 0 deletions include/vcl/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ class Image {
* Performs the set of operations that have been requested
* on the Image
*/

void perform_operations();

/**
Expand Down
22 changes: 9 additions & 13 deletions src/ImageCommand.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ VCL::Format ImageCommand::get_requested_format(const Json::Value &cmd) {
return VCL::Format::NONE_IMAGE;
}

//========= UpdateImage definitions =========
//========= AddImage definitions =========

AddImage::AddImage() : ImageCommand("AddImage") {
_storage_tdb = VDMSConfig::instance()->get_path_tdb();
Expand Down Expand Up @@ -231,7 +231,12 @@ int AddImage::construct_protobuf(PMGDQuery &query, const Json::Value &jsoncmd,

file_name = VCL::create_unique(img_root, format);

Json::Value ret;
// Modifiyng the existing properties that the user gives
// is a good option to make the AddNode more simple.
// This is not ideal since we are manupulating with user's
// input, but for now it is an acceptable solution.
Json::Value props = get_value<Json::Value>(cmd, "properties");
props[VDMS_IM_PATH_PROP] = file_name;

if (img.is_blob_not_stored()) {
props[VDMS_IM_PATH_PROP] = from_file_path;
Expand Down Expand Up @@ -261,11 +266,7 @@ bool AddImage::need_blob(const Json::Value &cmd) {
throw VCLException(UndefinedException, "Query Error");
}

if (findImage["status"] != 0) {
findImage["status"] = RSCommand::Error;
// Uses PMGD info error.
return error(findImage);
}
//========= UpdateImage definitions =========

UpdateImage::UpdateImage() : ImageCommand("UpdateImage") {}

Expand All @@ -283,12 +284,7 @@ int UpdateImage::construct_protobuf(PMGDQuery &query,
return 0;
}

if (findImage["entities"].size() == 0) {
Json::Value return_empty;
return_empty["status"] = RSCommand::Success;
return_empty["info"] = "No entities found";
return empty(return_empty);
}
//========= FindImage definitions =========

FindImage::FindImage() : ImageCommand("FindImage") {
_use_aws_storage = VDMSConfig::instance()->get_aws_flag();
Expand Down
2 changes: 1 addition & 1 deletion src/vcl/RemoteConnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -508,4 +508,4 @@ void RemoteConnection::printErrorMessage(const std::string &functionName,
std::cout << "Exception ocurred in RemoteConnection::printErrorMessage()."
<< " Error: " << ex.what() << std::endl;
}
}
}
15 changes: 0 additions & 15 deletions src/vcl/TDBObject.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,21 +274,6 @@ void TDBObject::set_attributes(const std::vector<std::string> &attributes) {
_attributes.push_back(charArrays[x]);
}
}
template void TDBObject::set_single_attribute(std::string &attribute,
CompressionType compressor,
int cell_val_num);
template void TDBObject::set_single_attribute(std::string &attribute,
CompressionType compressor,
uint64_t cell_val_num);
template void TDBObject::set_single_attribute(std::string &attribute,
CompressionType compressor,
long cell_val_num);
template void TDBObject::set_single_attribute(std::string &attribute,
CompressionType compressor,
float cell_val_num);
template void TDBObject::set_single_attribute(std::string &attribute,
CompressionType compressor,
unsigned char cell_val_num);

template <class T>
void TDBObject::set_single_attribute(std::string &attribute,
Expand Down
2 changes: 1 addition & 1 deletion tests/cleandbs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ rm -rf /tmp/trusted_server_key.pem || true
rm -rf /tmp/trusted_client_cert.pem || true
rm -rf /tmp/trusted_client_key.pem || true
rm -rf /tmp/untrusted_client_cert.pem || true
rm -rf /tmp/untrusted_client_key.pem || true
rm -rf /tmp/untrusted_client_key.pem || true
6 changes: 0 additions & 6 deletions tests/python/TestImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ def test_addImageWithLink(self):
# Verify the results
self.assertEqual(response[0]["AddEntity"]["status"], 0)
self.assertEqual(response[1]["AddImage"]["status"], 0)
self.disconnect(db)

def test_findImage_multiple_results(self):
# Setup
Expand Down Expand Up @@ -444,7 +443,6 @@ def test_findImage_multiple_results(self):
self.assertEqual(len(img_array), number_of_inserts)
self.assertEqual(response[0]["FindImage"]["status"], 0)
self.assertEqual(response[0]["FindImage"]["returned"], number_of_inserts)
self.disconnect(db)

# Verify the blob data returned is an array of PNG data
for img in img_array:
Expand Down Expand Up @@ -494,7 +492,6 @@ def test_findImageNoBlob(self):
)

self.assertEqual(len(img_array), 0)
self.disconnect(db)

def test_findImageRefNoBlobNoPropsResults(self):
# Setup
Expand Down Expand Up @@ -538,7 +535,6 @@ def test_findImageRefNoBlobNoPropsResults(self):
self.assertEqual(response[index]["FindImage"]["status"], 0)
self.assertEqual(response[index]["FindImage"]["info"], expected_info)
self.assertEqual(len(img_array), 0)
self.disconnect(db)

def test_updateImage(self):
# Setup
Expand Down Expand Up @@ -577,7 +573,6 @@ def test_updateImage(self):
self.assertEqual(response[0]["UpdateImage"]["count"], 1)
self.assertEqual(response[0]["UpdateImage"]["status"], 0)
self.assertEqual(len(img_array), 0)
self.disconnect(db)

# The following test fails:
# Error: "Object contains a property that could not be validated using
Expand Down Expand Up @@ -621,4 +616,3 @@ def test_zFindImageWithCollection(self):
# Verify the results
self.assertEqual(response[0]["FindImage"]["status"], 0)
self.assertEqual(len(img_array), number_of_inserts)
self.disconnect(db)
7 changes: 1 addition & 6 deletions tests/python/TestVideos.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ def test_addVideoFromLocalFile_invalid_command(self):
self.disconnect(db)

self.assertEqual(response[0]["status"], -1)
self.disconnect(db)

def test_addVideoFromLocalFile_file_not_found(self):
db = self.create_connection()
Expand All @@ -193,7 +192,6 @@ def test_addVideoFromLocalFile_file_not_found(self):
self.disconnect(db)

self.assertEqual(response[0]["status"], -1)
self.disconnect(db)

@TestCommand.TestCommand.shouldSkipRemotePythonTest()
def test_addVideoFromLocalFile_success(self):
Expand Down Expand Up @@ -290,7 +288,6 @@ def test_findVideo(self):
self.assertEqual(len(vid_array), number_of_inserts)
for i in range(0, number_of_inserts):
self.assertEqual(response[i]["FindVideo"]["status"], 0)
self.disconnect(db)

for vid in vid_array:
self.verify_mp4_signature(vid)
Expand Down Expand Up @@ -372,7 +369,6 @@ def test_FindFramesByInterval(self):
self.assertEqual(response[0]["FindFrames"]["status"], 0)
self.assertEqual(response[1]["FindFrames"]["status"], 0)
self.assertEqual(len(img_array), 2 * number_of_frames)
self.disconnect(db)

for img in img_array:
self.verify_png_signature(img)
Expand Down Expand Up @@ -473,7 +469,6 @@ def test_findVideoResults(self):
self.assertEqual(len(vid_array), number_of_inserts)
for i in range(0, number_of_inserts):
self.assertEqual(response[i]["FindVideo"]["status"], 0)
self.disconnect(db)

for vid in vid_array:
self.verify_mp4_signature(vid)
Expand Down Expand Up @@ -555,6 +550,7 @@ def test_findVid_multiple_results(self):

prefix_name = "vid_multiple"
number_of_inserts = 4

for i in range(0, number_of_inserts):
props = {}
props["name"] = prefix_name
Expand Down Expand Up @@ -621,7 +617,6 @@ def test_findVideoNoBlob(self):
for index in range(0, number_of_inserts):
self.assertEqual(response[index]["FindVideo"]["status"], 0)
self.assertEqual(len(img_array), 0)
self.disconnect(db)

def test_updateVideo(self):
db = self.create_connection()
Expand Down
91 changes: 0 additions & 91 deletions tests/unit_tests/Image_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1037,94 +1037,3 @@ TEST_F(ImageTest, ImagePathError) {
ASSERT_THROW(read_img.get_encoded_image_async(read_img.get_image_format()),
VCL::Exception);
}

TEST_F(ImageTest, ImageLoopURLError) {
VCL::Image img(img_);
ImageLoop imageLoop;

std::string _url = "http://localhost:5010/imag";
Json::Value _options;
_options["format"] = "jpg";
_options["id"] = "flip";

img.flip(0);
img.remoteOperation(_url, _options);

imageLoop.set_nrof_entities(1);

imageLoop.enqueue(&img);

while (imageLoop.is_loop_running()) {
continue;
}

std::map<std::string, VCL::Image *> imageMap = imageLoop.get_image_map();
std::map<std::string, VCL::Image *>::iterator iter = imageMap.begin();

ASSERT_TRUE(iter->second->get_query_error_response() != "");
}

TEST_F(ImageTest, ImageLoopRemoteFunctionError) {
VCL::Image img(img_);
ImageLoop imageLoop;

std::string _url = "http://localhost:5010/image";
Json::Value _options;
_options["format"] = "jpg";
_options["id"] = "gray";

img.flip(0);
img.remoteOperation(_url, _options);

imageLoop.set_nrof_entities(1);

imageLoop.enqueue(&img);

while (imageLoop.is_loop_running()) {
continue;
}

std::map<std::string, VCL::Image *> imageMap = imageLoop.get_image_map();
std::map<std::string, VCL::Image *>::iterator iter = imageMap.begin();

ASSERT_TRUE(iter->second->get_query_error_response() != "");
}

TEST_F(ImageTest, ImageLoopSyncRemoteFunctionError) {
VCL::Image img(img_);
ImageLoop imageLoop;

std::string _url = "http://localhost:5010/imag";
Json::Value _options;
_options["format"] = "jpg";
_options["id"] = "gray";

img.flip(0);
img.syncremoteOperation(_url, _options);

imageLoop.set_nrof_entities(1);

imageLoop.enqueue(&img);

while (imageLoop.is_loop_running()) {
continue;
}

std::map<std::string, VCL::Image *> imageMap = imageLoop.get_image_map();
std::map<std::string, VCL::Image *>::iterator iter = imageMap.begin();

ASSERT_TRUE(iter->second->get_query_error_response() != "");
}

TEST_F(ImageTest, PipelineException) {
VCL::Image img(img_);

img.threshold(100);
img.flip(0);
img.resize(50, 80);
img.crop(bad_rect_);

img.get_cvmat();
ASSERT_STREQ(img.get_query_error_response().data(),
"Requested area is not within the image");
}
1 change: 0 additions & 1 deletion tests/unit_tests/Video_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ TEST_F(VideoTest, IntervalWrite) {
}
}
}
}

if (frame_number > end) {
break;
Expand Down
3 changes: 1 addition & 2 deletions tests/unit_tests/helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
#include <random>
#include <vector>

void compare_mat_mat(cv::Mat &cv_img, cv::Mat &img, float error) {
bool exact_comparison = (error == 0.0);
// Image / Video Helpers

// source:
// https://github.com/MasteringOpenCV/code/blob/master/Chapter8_FaceRecognition/recognition.cpp
Expand Down

0 comments on commit fb6070e

Please sign in to comment.