TITANIUM_PROPERTY_SETTER(View, annotations) { if (!argument.IsObject()) { return false; } const auto annotations = static_cast<JSObject>(argument); if (!annotations.IsArray()) { return false; } set_annotations(static_cast<JSArray>(annotations).GetPrivateItems<Annotation>()); return true; }
MetaData_YML_Backed* load_ICL(string base_path,string annotation,bool training) { // parse the annotation vector<double> labels; istringstream iss(annotation); string filename; iss >> filename; // discard. cout << "annotation " << annotation << endl; cout << "filename " << filename << endl; while(iss) { double v; iss >> v; labels.push_back(v); } // calc the name for this metadata string metadata_filename = base_path + filename; // load the raw data float active_min = training?0:params::MIN_Z(); string frame_file = base_path + filename; Mat depth = imread(frame_file,-1); assert(!depth.empty()); CustomCamera pxc_camera(params::H_RGB_FOV,params::V_RGB_FOV, depth.cols,depth.rows); depth.convertTo(depth,DataType<float>::type); depth /= 10; for(int rIter = 0; rIter < depth.rows; ++rIter) for(int cIter = 0; cIter < depth.cols; ++cIter) { float & d = depth.at<float>(rIter,cIter); if(d <= active_min) d = inf; } //depth = pointCloudToDepth(depth,pxc_camera); if(depth.empty()) { log_once(printfpp("ICL_Video cannot load %s",metadata_filename.c_str())); log_once(printfpp("Couldn't open %s",frame_file.c_str())); return nullptr; } //Mat RGB (depth.rows,depth.cols,DataType<Vec3b>::type,Scalar(122,150,233)); Mat RGB = imageeq("",depth,false,false); for(int rIter = 0; rIter < RGB.rows; rIter++) for(int cIter = 0; cIter < RGB.cols; cIter++) RGB.at<Vec3b>(rIter,cIter)[2] = 255; // create an image shared_ptr<ImRGBZ> im = make_shared<ImRGBZ>(RGB,depth,metadata_filename + "image",pxc_camera); // create the metadata object Metadata_Simple* metadata = new Metadata_Simple(metadata_filename+".yml",true,true,false); metadata->setIm(*im); Point2d hand_root(labels[0 + 0*3],labels[1 + 0*3]); suppress_flood_fill_hack(im->Z,hand_root); metadata->setIm(*im); Rect handBB = set_annotations(metadata,labels,im); suppress_most_common_pixel_hack(im->Z,handBB); metadata->setIm(*im); log_im_decay_freq("ICL_loaded",[&]() { return image_datum(*metadata); }); return metadata; }