提交 aa997199 编写于 作者: S sjtubinlong

fix bugs

上级 41606c13
...@@ -87,8 +87,8 @@ cv::Mat HumanSeg::Postprocess(const cv::Mat& im) { ...@@ -87,8 +87,8 @@ cv::Mat HumanSeg::Postprocess(const cv::Mat& im) {
im_scoremap.convertTo(im_scoremap, CV_32FC1, 1 / 255.0); im_scoremap.convertTo(im_scoremap, CV_32FC1, 1 / 255.0);
float* pblob = reinterpret_cast<float*>(im_scoremap.data); float* pblob = reinterpret_cast<float*>(im_scoremap.data);
int out_buff_len = im.cols * im.rows * sizeof(uchar); int out_buff_capacity = 10 * im.cols * im.rows * sizeof(float);
segout_data_.resize(out_buff_len); segout_data_.resize(out_buff_capacity);
unsigned char* seg_result = segout_data_.data(); unsigned char* seg_result = segout_data_.data();
MergeProcess(im.data, pblob, im.rows, im.cols, seg_result); MergeProcess(im.data, pblob, im.rows, im.cols, seg_result);
cv::Mat seg_mat(im.rows, im.cols, CV_8UC1, seg_result); cv::Mat seg_mat(im.rows, im.cols, CV_8UC1, seg_result);
......
...@@ -254,7 +254,7 @@ cv::Mat MergeSegMat(const cv::Mat& seg_mat, ...@@ -254,7 +254,7 @@ cv::Mat MergeSegMat(const cv::Mat& seg_mat,
int ThresholdMask(const cv::Mat &fg_cfd, int ThresholdMask(const cv::Mat &fg_cfd,
const float fg_thres, const float fg_thres,
const float bg_thres, const float bg_thres,
cv::Mat fg_mask) { cv::Mat& fg_mask) {
if (fg_cfd.type() != CV_32FC1) { if (fg_cfd.type() != CV_32FC1) {
printf("ThresholdMask: type is not CV_32FC1.\n"); printf("ThresholdMask: type is not CV_32FC1.\n");
return -1; return -1;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
int ThresholdMask(const cv::Mat &fg_cfd, int ThresholdMask(const cv::Mat &fg_cfd,
const float fg_thres, const float fg_thres,
const float bg_thres, const float bg_thres,
cv::Mat fg_mask); cv::Mat& fg_mask);
cv::Mat MergeSegMat(const cv::Mat& seg_mat, cv::Mat MergeSegMat(const cv::Mat& seg_mat,
const cv::Mat& ori_frame); const cv::Mat& ori_frame);
......
...@@ -41,13 +41,16 @@ int VideoPredict(const std::string& video_path, HumanSeg& seg) ...@@ -41,13 +41,16 @@ int VideoPredict(const std::string& video_path, HumanSeg& seg)
printf("create video writer failed!\n"); printf("create video writer failed!\n");
return -1; return -1;
} }
cv::Mat frame; cv::Mat frame;
while (capture.read(frame)) { while (capture.read(frame)) {
if (frame.empty()) {
break;
}
cv::Mat out_im = seg.Predict(frame); cv::Mat out_im = seg.Predict(frame);
video_out.write(out_im); video_out.write(out_im);
} }
capture.release(); capture.release();
video_out.release();
return 0; return 0;
} }
...@@ -79,10 +82,10 @@ int main(int argc, char* argv[]) { ...@@ -79,10 +82,10 @@ int main(int argc, char* argv[]) {
// Call ImagePredict while input_path is a image file path // Call ImagePredict while input_path is a image file path
// The output will be saved as result.jpeg // The output will be saved as result.jpeg
ImagePredict(input_path, seg); // ImagePredict(input_path, seg);
// Call VideoPredict while input_path is a video file path // Call VideoPredict while input_path is a video file path
// The output will be saved as result.avi // The output will be saved as result.avi
// VideoPredict(input_path, seg); VideoPredict(input_path, seg);
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册