mirror of
https://github.com/gosticks/openpose.git
synced 2026-08-12 04:10:28 +00:00
More security checks on cvMatToOutput & updated hand test
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
# Script for internal use. We might completely change it continuously and we will not answer questions about it.
|
||||
# Usage example:
|
||||
# clear && clear && make all -j`nproc` && bash ./examples/tests/hand_accuracy_test.sh
|
||||
|
||||
# Disclaimer:
|
||||
# Script for internal use. We might make continuous changess on it and we will not answer questions about it.
|
||||
|
||||
# Clear terminal screen
|
||||
clear && clear
|
||||
|
||||
|
||||
|
||||
HAND_TESTING_FOLDER="/media/posefs3b/Users/gines/openpose_training/dataset/hand_testing/5_keypointJson/"
|
||||
HAND_TESTING_FOLDER="/media/posefs3b/Users/gines/openpose_train/dataset/hand_testing/"
|
||||
IMAGES_FOLDER=${HAND_TESTING_FOLDER}"0_images/"
|
||||
IMAGES_BB_FOLDER=${HAND_TESTING_FOLDER}"3_images_bounding_box"
|
||||
IMAGES_BB_FOLDER=${HAND_TESTING_FOLDER}"4_hand_detections"
|
||||
HAND_GROUND_TRUTH_FOLDER=${HAND_TESTING_FOLDER}"4_hand_detections"
|
||||
KEYPOINT_JSON_FOLDER=${HAND_TESTING_FOLDER}"5_keypointJson/"
|
||||
|
||||
SCALES=6
|
||||
@@ -24,9 +28,9 @@ rm -rf $HAND_RESULTS_FOLDER_BB
|
||||
./build/examples/tests/handFromJsonTest.bin \
|
||||
--hand_scale_number ${SCALES} --hand_scale_range 0.4 \
|
||||
--image_dir ${IMAGES_BB_FOLDER} \
|
||||
--hand_ground_truth ${IMAGES_BB_FOLDER} \
|
||||
--write_keypoint_json $HAND_RESULTS_FOLDER_BB \
|
||||
--no_display
|
||||
--hand_ground_truth ${HAND_GROUND_TRUTH_FOLDER}
|
||||
# --write_keypoint_json $HAND_RESULTS_FOLDER_BB \
|
||||
# --no_display
|
||||
|
||||
|
||||
|
||||
@@ -36,8 +40,7 @@ echo "Output on ${HAND_RESULTS_FOLDER_NO_BB}"
|
||||
rm -rf $HAND_RESULTS_FOLDER_NO_BB
|
||||
# 1 scale
|
||||
./build/examples/openpose/openpose.bin \
|
||||
--hand logging_level 3 \
|
||||
--hand_scale_number ${SCALES} --hand_scale_range 0.4 \
|
||||
--image_dir ${IMAGES_FOLDER} \
|
||||
--write_keypoint_json $HAND_RESULTS_FOLDER_NO_BB \
|
||||
--no_display
|
||||
--hand --hand_scale_number ${SCALES} --hand_scale_range 0.4 \
|
||||
--image_dir ${IMAGES_FOLDER} #\
|
||||
# --write_keypoint_json $HAND_RESULTS_FOLDER_NO_BB \
|
||||
# --no_display
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace op
|
||||
// Workers
|
||||
TWorker wDatumProducer;
|
||||
TWorker spWIdGenerator;
|
||||
TWorker spWScaleAndSizeExtractor;
|
||||
TWorker spWCvMatToOpInput;
|
||||
TWorker spWCvMatToOpOutput;
|
||||
std::vector<std::vector<TWorker>> spWPoses;
|
||||
@@ -172,6 +173,13 @@ namespace op
|
||||
const auto datumProducer = std::make_shared<DatumProducer<TDatums>>(producerSharedPtr);
|
||||
wDatumProducer = std::make_shared<WDatumProducer<TDatumsPtr, TDatums>>(datumProducer);
|
||||
|
||||
// Get input scales and sizes
|
||||
const auto scaleAndSizeExtractor = std::make_shared<ScaleAndSizeExtractor>(
|
||||
wrapperStructPose.netInputSize, finalOutputSize, wrapperStructPose.scalesNumber,
|
||||
wrapperStructPose.scaleGap
|
||||
);
|
||||
spWScaleAndSizeExtractor = std::make_shared<WScaleAndSizeExtractor<TDatumsPtr>>(scaleAndSizeExtractor);
|
||||
|
||||
// Input cvMat to OpenPose format
|
||||
const auto cvMatToOpInput = std::make_shared<CvMatToOpInput>();
|
||||
spWCvMatToOpInput = std::make_shared<WCvMatToOpInput<TDatumsPtr>>(cvMatToOpInput);
|
||||
@@ -281,6 +289,7 @@ namespace op
|
||||
mThreadManager.reset();
|
||||
// Reset
|
||||
wDatumProducer = nullptr;
|
||||
spWScaleAndSizeExtractor = nullptr;
|
||||
spWCvMatToOpInput = nullptr;
|
||||
spWCvMatToOpOutput = nullptr;
|
||||
spWPoses.clear();
|
||||
@@ -301,7 +310,8 @@ namespace op
|
||||
{
|
||||
// Security checks
|
||||
if (spWCvMatToOpInput == nullptr)
|
||||
error("Configure the WrapperHandFromJsonTest class before calling `start()`.", __LINE__, __FUNCTION__, __FILE__);
|
||||
error("Configure the WrapperHandFromJsonTest class before calling `start()`.",
|
||||
__LINE__, __FUNCTION__, __FILE__);
|
||||
if (wDatumProducer == nullptr)
|
||||
{
|
||||
const auto message = "You need to use the OpenPose default producer.";
|
||||
@@ -323,9 +333,11 @@ namespace op
|
||||
// OpenPose producer
|
||||
// Thread 0 or 1, queues 0 -> 1
|
||||
if (spWCvMatToOpOutput == nullptr)
|
||||
mThreadManager.add(threadId++, {wDatumProducer, spWIdGenerator, spWCvMatToOpInput}, queueIn++, queueOut++);
|
||||
mThreadManager.add(threadId++, {wDatumProducer, spWIdGenerator, spWScaleAndSizeExtractor,
|
||||
spWCvMatToOpInput}, queueIn++, queueOut++);
|
||||
else
|
||||
mThreadManager.add(threadId++, {wDatumProducer, spWIdGenerator, spWCvMatToOpInput, spWCvMatToOpOutput}, queueIn++, queueOut++);
|
||||
mThreadManager.add(threadId++, {wDatumProducer, spWIdGenerator, spWScaleAndSizeExtractor,
|
||||
spWCvMatToOpInput, spWCvMatToOpOutput}, queueIn++, queueOut++);
|
||||
// Pose estimation & rendering
|
||||
// Thread 1 or 2...X, queues 1 -> 2, X = 2 + #GPUs
|
||||
if (!spWPoses.empty())
|
||||
|
||||
@@ -12,6 +12,10 @@ namespace op
|
||||
error("Wrong input element (empty cvInputData).", __LINE__, __FUNCTION__, __FILE__);
|
||||
if (cvInputData.channels() != 3)
|
||||
error("Input images must be 3-channel BGR.", __LINE__, __FUNCTION__, __FILE__);
|
||||
if (cvInputData.cols <= 0 || cvInputData.rows <= 0)
|
||||
error("Input images has 0 area.", __LINE__, __FUNCTION__, __FILE__);
|
||||
if (outputResolution.x <= 0 || outputResolution.y <= 0)
|
||||
error("Output resolution has 0 area.", __LINE__, __FUNCTION__, __FILE__);
|
||||
// outputData - Reescale keeping aspect ratio and transform to float the output image
|
||||
const cv::Mat frameWithOutputSize = resizeFixedAspectRatio(cvInputData, scaleInputToOutput,
|
||||
outputResolution);
|
||||
|
||||
Reference in New Issue
Block a user