void PutDone(obex_object_t* object) { obex_headerdata_t hv; uint8_t hi; int hlen; const uint8_t *body = NULL; int bodylen = 0; char* name = NULL; char* namebuf = NULL; int nooverwrite = 0; while (OBEX_ObjectGetNextHeader(handleRcv, object, &hi, &hv, (uint32_t*)&hlen)) { switch (hi) { case OBEX_HDR_BODY: body = hv.bs; bodylen = hlen; break; case OBEX_HDR_NAME: if ( (namebuf = malloc(hlen / 2))) { /* OBEX_UnicodeToChar((uint8_t*)namebuf, hv.bs, hlen);*/ strcpy(namebuf, hv.bs); name = namebuf; } break; case OBEX_HDR_LENGTH: printf("HEADERLENGTH = %d\n", hv.bq4); break; case HEADER_CREATOR_ID: printf("CREATORID = %#x\n", hv.bq4); break; default: /*printf(FUNCTION "() Skipped header %02x\n", hi);*/ printf(" Skipped header %02x\n", hi); } } nooverwrite = TargetExist(name); if (nooverwrite == 0) { printf("A file named %s already exists in %s - I will not overwrite it.", name, rcvDir); } else { if (!body) { printf("Got a PUT without a body\n"); return; } if (!name) { printf("Got a PUT without a name. Setting name to %s\n", name); name = "OBEX PUT Unknown object"; } SaveSafely(name, body, bodylen); } free(namebuf); }
bool inpainting::Process(void) { char path[200]; char temp[30]; Convert2Gray(); DrawBoundary(); DrawSource(); memset(m_pri, 0, m_width*m_height*sizeof(double)); for(int j= m_top; j <= m_bottom; ++j) { for(int i = m_left; i <= m_right; ++i) { if(m_mark[j * m_width + i] == SOURCE) { number_to_fill_y[j] += 1; number_to_fill_x[i] += 1; if(number_to_fill_y[j]>max_width) { max_width=number_to_fill_y[j]; } if(number_to_fill_x[i]>max_height) { max_height=number_to_fill_x[i]; } } if(m_mark[j * m_width + i] == BOUNDARY) { m_pri[j * m_width + i] = ComputePriority(i,j); number_to_fill_y[j] += 1; number_to_fill_x[i] += 1; } } } int count=0; while(TargetExist()) { count++; double max_pri = 0; int pri_x,pri_y; for(int j= m_top; j <= m_bottom; ++j) { for(int i = m_left; i <= m_right; ++i) { if(m_mark[j * m_width + i] == BOUNDARY&&m_pri[j * m_width + i]>max_pri) { pri_x = i; pri_y = j; max_pri = m_pri[j * m_width + i]; } } } int patch_x, patch_y; PatchTexture(pri_x, pri_y, patch_x, patch_y); FillTarget(pri_x, pri_y, patch_x,patch_y, ComputeConfidence(pri_x,pri_y)); UpdateBoundary(pri_x, pri_y); UpdatePriority(pri_x, pri_y); } strcpy(path, save_path); strcat(path, ".bmp"); Image->Save(path); return true; }
std::string inpainting::Process(void) { char path[200]; char temp[30]; pix_to_inpaint = 0; pix_been_inpainted = 0; Convert2Gray(); DrawBoundary(); DrawSource(); memset(m_pri, 0, m_width*m_height*sizeof(double)); for (int j= m_top; j <= m_bottom; ++j) { for (int i = m_left; i <= m_right; ++i) { if (m_mark[j * m_width + i] == BOUNDARY) { m_pri[j * m_width + i] = ComputePriority(i, j); } } } int count = 0; count_pic =1; int temp_color = 0; int temp_color2 = 0; int *temp_colors = new int[LOOKUP]; int *temp_colors_2 = new int[LOOKUP]; int **most_similar_patch = new int*[LOOKUP]; for (int o = 0; o < LOOKUP; ++o) { most_similar_patch[o] = new int[2]; } int **most_similar_patch_2 = new int*[LOOKUP]; for (int o = 0; o < LOOKUP; ++o) { most_similar_patch_2[o] = new int[2]; } int start = clock(); int *colum_in_height = new int[m_height]; for (int i = 0; i < m_height; ++i) { colum_in_height[i] = 0; } int *colum_in_width = new int[m_width]; for (int i = 0; i < m_width; ++i) { colum_in_width[i] = 0; } double max_pri = 0; int pri_x, pri_y; int patch_x, patch_y; while (TargetExist()) { count++; count_pic++; max_pri = 0; for (int j= 0; j < m_height; ++j) { for (int i = 0; i < m_width; ++i) { colum_in_height[j]++; colum_in_width[i]++; if (m_mark[j * m_width + i] == BOUNDARY && m_pri[j * m_width + i] > max_pri) { pri_x = i; pri_y = j; max_pri = m_pri[j * m_width + i]; colum_in_height[j]--; colum_in_width[i]--; } if (m_mark[j * m_width + i] == TARGET) { colum_in_height[j]--; colum_in_width[i]--; } } } height_diff = m_bottom - m_top + 1; width_diff = m_right - m_left + 1; // 缩小搜索框 for (int i = m_top; i <= m_bottom; ++i) { if (colum_in_height[i] == width_diff) { m_top++; } else { break; } } for (int i = m_bottom-1; i >= m_top; --i) { if (colum_in_height[i] == width_diff) { m_bottom--; } else { break; } } for (int i = m_left; i <= m_right; ++i) { if (colum_in_width[i] == height_diff) { m_left++; } else { break; } } for (int i = m_right; i >= m_left; --i) { if (colum_in_width[i] == height_diff) { m_right--; } else { break; } } PatchTexture(pri_x, pri_y, patch_x, patch_y, most_similar_patch, most_similar_patch_2); FillTarget(pri_x, pri_y, patch_x, patch_y, ComputeConfidence(pri_x, pri_y)); UpdateBoundary(pri_x, pri_y); UpdatePriority(pri_x, pri_y); char str[10]; sprintf(str, "%d", count); strcpy(path, save_path); strcat(path, str); strcat(path, ".bmp"); // cout<<" path = "<<path<<endl; // Image -> save(path); // 下面的是为了画出最匹配的20个点的图片的中间步骤 /*temp_color = Image->pixel(pri_x,pri_y); temp_color2 = Image->pixel(patch_x,patch_y); for(int o=0;o<LOOKUP;++o) { temp_colors[o]=Image->pixel(most_similar_patch[o][0],most_similar_patch[o][1]); // temp_colors_2[o]=Image->pixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1]); Image -> setPixel(most_similar_patch[o][0],most_similar_patch[o][1],MARK); // Image -> setPixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1],MARK2); } Image -> setPixel(pri_x,pri_y,RED); Image -> setPixel(patch_x,patch_y,BLUE); //cout<<" patch_x = "<<patch_x<<endl; //cout<<" patch_y = "<<patch_y<<endl; Image -> save(path); for(int o=0;o<LOOKUP;++o) { Image -> setPixel(most_similar_patch[o][0],most_similar_patch[o][1],temp_colors[o]); // Image -> setPixel(most_similar_patch_2[o][0],most_similar_patch_2[o][1],temp_colors_2[o]); } Image -> setPixel(pri_x,pri_y,temp_color); Image -> setPixel(patch_x,patch_y,temp_color2);*/ } int end = clock(); strcpy(path, save_path); strcat(path, ".bmp"); // Image->Save(path); std::string res = path; return res; }