void edge_difference(const cv::Mat& src1, const cv::Mat& src2, cv::Mat& edge1, cv::Mat& edge2, double canny_thresh1, double canny_thresh2, int aperture_size, int dilate_size){ assert(src1.size()==src2.size()); cv::Mat gray1,gray2; if(src1.channels()==1){ gray1 = src1.clone(); } else{ gray1 = cv::Mat(src1.size(),CV_8UC1); cv::cvtColor(src1,gray1,CV_BGR2GRAY); } if(src2.channels()==1){ gray2 = src2.clone(); } else{ gray2 = cv::Mat(src2.size(),CV_8UC1); cv::cvtColor(src2,gray2,CV_BGR2GRAY); } cv::Mat _edge1 = cv::Mat(src1.size(),CV_8UC1); cv::Mat _edge2 = cv::Mat(src2.size(),CV_8UC1); cv::Canny(gray1,_edge1, canny_thresh1, canny_thresh2, aperture_size); cv::Canny(gray2,_edge2, canny_thresh1, canny_thresh2, aperture_size); #ifdef DEBUG_SKLUTILS cv::namedWindow("edge1",0); cv::namedWindow("edge2",0); cv::imshow("edge1",_edge1); cv::imshow("edge2",_edge2); #endif cv::Size kernel_size(dilate_size,dilate_size); cv::Mat dick_edge1 = cv::Mat(src1.size(),CV_8UC1); cv::Mat dick_edge2 = cv::Mat(src2.size(),CV_8UC1); cv::blur(_edge1,dick_edge1,kernel_size); cv::threshold(dick_edge1,dick_edge1,0,255,CV_THRESH_BINARY); cv::blur(_edge2,dick_edge2,kernel_size); cv::threshold(dick_edge2,dick_edge2,0,255,CV_THRESH_BINARY); edge1 = _edge1 - dick_edge2; edge2 = _edge2 - dick_edge1; /// /* cv::imwrite("src.png",src1); cv::imwrite("fg_edge.png",edge1); cv::imwrite("src_fg_edge.png",_edge1); cv::imwrite("bg_edge_dick.png",dick_edge2); cv::imwrite("bg.png",src2); cv::imwrite("bg_edge.png",edge2); cv::imwrite("src_bg_edge.png",_edge2); cv::imwrite("fg_edge_dick.png",dick_edge1); */ /// }
static int update_image_length(struct spi_flash *flash, unsigned int offset, unsigned char *dest, unsigned char flag) { unsigned int length = flash->page_size; int ret; ret = spi_flash_read(flash, offset, length, dest); if (ret) return -1; if (flag == KERNEL_IMAGE) return kernel_size(dest); #ifdef CONFIG_OF_LIBFDT else { ret = check_dt_blob_valid((void *)dest); if (!ret) return of_get_dt_total_size((void *)dest); } #endif return -1; }