LLColor4U lggBeamMaps::getCurrentColor(LLColor4U agentColor) { static std::string* settingName = rebind_llcontrol<std::string >("EmeraldBeamColorFile", &gSavedSettings, true); if(*settingName == "===OFF===") return agentColor; if(*settingName != lastColorFileName) { lastColorFileName = *settingName; std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beamsColors", "")); std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beamsColors", "")); std::string filename = path_name + *settingName + ".xml"; if(gDirUtilp->fileExists(filename)) { }else { filename = path_name2 + *settingName + ".xml"; if(!gDirUtilp->fileExists(filename)) { return agentColor; } } lastColorsData = lggBeamsColors::fromLLSD(getPic(filename)); } agentColor = beamColorFromData(lastColorsData); return agentColor; }
//this function is called after each timeout, which iterates the CA gint loopThrough(gpointer data) { //if autoReset is toggled, find if row is all black or all white, // and reset if it is either if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autoResetButton))) { int sum = ca1->getRowSum(); if ((sum < ROW_LOWER_BOUND) || (sum > DEFAULT_WIDTH)) { ca1->resetCells(); } } //if meta-rules have been loaded, apply them here if (rules.size() > 0) { if ((numLines % ruleChangeInterval == 0) && (numLines != 0)) { int seed = rand() % rules.size(); ca1->setRule(rules[seed]); std::cout << "changing rule to " << rules[seed] << std::endl; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(randomizeLengthButton))) { ruleChangeInterval=rand() % maxRuleChangeInterval + 1; } } } //calculate the new row, iterate the automaton ca1->calcNewRow(); //redraw the image redrawImage(); //if auto-saving pics, activate here if ((numLines % HEIGHT == 0) && savePics) { getPic(data); } return TRUE; }
LLColor4U lggBeamMaps::getCurrentColor(const LLColor4U& agentColor) { static LLCachedControl<std::string> settingName(gSavedSettings, "FSBeamColorFile"); std::string setName(settingName); if (setName.empty()) { return agentColor; } if (setName != mLastColorFileName) { mLastColorFileName = settingName; std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beamsColors", "")); std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "beamsColors", "")); std::string filename = path_name + setName + ".xml"; if (!gDirUtilp->fileExists(filename)) { filename = path_name2 + setName + ".xml"; if (!gDirUtilp->fileExists(filename)) { return agentColor; } } mLastColorsData = lggBeamsColors::fromLLSD(getPic(filename)); } return beamColorFromData(mLastColorsData); }
LLColor4U lggBeamMaps::getCurrentColor(LLColor4U agentColor) { static LLCachedControl<std::string> ssettingName(gSavedSettings, "PhoenixBeamColorFile"); std::string settingName = std::string(ssettingName); if(settingName == "===OFF===") return agentColor; if(settingName != lastColorFileName) { lastColorFileName = settingName; std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beamsColors", "")); std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beamsColors", "")); std::string filename = path_name + settingName + ".xml"; if(gDirUtilp->fileExists(filename)) { } else { filename = path_name2 + settingName + ".xml"; if(!gDirUtilp->fileExists(filename)) { return agentColor; } } lastColorsData = lggBeamsColors::fromLLSD(getPic(filename)); } agentColor = beamColorFromData(lastColorsData); return agentColor; }
F32 lggBeamMaps::setUpAndGetDuration() { static LLCachedControl<std::string> settingNameCached(gSavedSettings, "FSBeamShape"); std::string settingName(settingNameCached); if(settingName != lastFileName) { lastFileName = settingName; if( settingName != "===OFF===" && settingName != "") { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beams", "")); std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "beams", "")); std::string filename = path_name + settingName + ".xml"; if (!gDirUtilp->fileExists(filename)) { filename =path_name2 + settingName +".xml"; } LLSD mydata = getPic(filename); scale = (F32)mydata["scale"].asReal()/10.0f; LLSD myPicture = mydata["data"]; dots.clear(); for (int i = 0; i < myPicture.size(); i++) { LLSD beamData = myPicture[i]; lggBeamData dot; dot.p = LLVector3d(beamData["offset"]); // <FS:PP> Attempt to speed up things a little // dot.p *= (gSavedSettings.getF32("FSBeamShapeScale")*2.0f); static LLCachedControl<F32> FSBeamShapeScale(gSavedSettings, "FSBeamShapeScale"); dot.p *= (FSBeamShapeScale*2.0f); // </FS:PP> LLColor4 color = LLColor4(beamData["color"]); dot.c = LLColor4U(color); dots.push_back(dot); } // <FS:PP> Attempt to speed up things a little // F32 maxBPerQS = gSavedSettings.getF32("FSMaxBeamsPerSecond") / 4.0f; static LLCachedControl<F32> FSMaxBeamsPerSecond(gSavedSettings, "FSMaxBeamsPerSecond"); F32 maxBPerQS = FSMaxBeamsPerSecond / 4.0f; // </FS:PP> duration = llceil((F32)(myPicture.size()) / maxBPerQS) * 0.25f; llinfos << "reading it all now size is " << myPicture.size() << " and duration is " << duration << llendl; } else { dots.clear(); scale = 0.0f;//used as a flag too duration = 0.25f; } } //llinfos << "sent final dur of " << duration << llendl; return duration; }
gfxr_pic_t *GfxResManager::addToPic(int old_nr, int new_nr, int flags, int old_default_palette, int default_palette) { IntResMap &resMap = _resourceMaps[GFX_RESOURCE_TYPE_PIC]; gfxr_pic_t *pic = NULL; gfx_resource_t *res = NULL; int hash = getOptionsHash(GFX_RESOURCE_TYPE_PIC); #ifdef CUSTOM_GRAPHICS_OPTIONS int need_unscaled = !(_options->pic0_unscaled) && (_driver->getMode()->xfact != 1 || _driver->getMode()->yfact != 1); #else int need_unscaled = 1; #endif res = resMap.contains(old_nr) ? resMap[old_nr] : NULL; if (!res || (res->mode != MODE_INVALID && res->mode != hash)) { getPic(old_nr, 0, flags, old_default_palette, 1); res = resMap.contains(old_nr) ? resMap[old_nr] : NULL; if (!res) { warning("[GFX] Attempt to add pic %d to non-existing pic %d", new_nr, old_nr); return NULL; } } #ifdef CUSTOM_GRAPHICS_OPTIONS if (_options->pic0_unscaled) // Unscale priority map, if we scaled it earlier #endif _gfxr_unscale_pixmap_index_data(res->scaled_data.pic->priority_map, _driver->getMode()); // The following two operations are needed when returning scaled maps (which is always the case here) #ifdef CUSTOM_GRAPHICS_OPTIONS res->lock_sequence_nr = _options->buffer_pics_nr; #else res->lock_sequence_nr = 0; #endif calculatePic(res->scaled_data.pic, need_unscaled ? res->unscaled_data.pic : NULL, flags | DRAWPIC01_FLAG_OVERLAID_PIC, default_palette, new_nr); res->mode = MODE_INVALID; // Invalidate #ifdef CUSTOM_GRAPHICS_OPTIONS if (_options->pic0_unscaled) // Scale priority map again, if needed #endif res->scaled_data.pic->priority_map = gfx_pixmap_scale_index_data(res->scaled_data.pic->priority_map, _driver->getMode()); { int old_ID = get_pic_id(res); set_pic_id(res, GFXR_RES_ID(GFX_RESOURCE_TYPE_PIC, new_nr)); // To ensure that our graphical translation options work properly #ifdef CUSTOM_GRAPHICS_OPTIONS pic = gfxr_pic_xlate_common(res, GFX_MASK_VISUAL, 1, 1, _driver->getMode(), _options->pic_xlate_filter, _options); #else pic = gfxr_pic_xlate_common(res, GFX_MASK_VISUAL, 1, 1, _driver->getMode(), GFX_XLATE_FILTER_NONE, _options); #endif set_pic_id(res, old_ID); } return pic; }
DownloadPicture::DownloadPicture(QObject *parent) : QObject(parent) { manager = new QNetworkAccessManager(this); connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*))); connect(this,SIGNAL(getOnePic()),this,SLOT(getPic())); }
int main ( int argc, char *argv[] ) { Param params; FlowCom *comPtr = NULL; char line [ LINE_LEN ]; while ( argc > 1 ) { if ( !strcmp( argv[1], "-D" ) ) { setDebugFlag(); } else if ( !strcmp( argv[1], "-V" ) ) { printf ( "%s\n", VERSION ); exit ( 0 ); } else { break; } argv++; argc--; } open_tempfile(); open_infile ( ( argc > 1 ) ? argv[ 1 ] : NULL ); tprintf ( "%% picture environment flowchart generated by flow " ); tprintf ( "%s\n", VERSION ); while ( readline_infile ( line, LINE_LEN ) != NULL ) { if ( ( comPtr = getCommand ( line, params ) ) != NULL ) { switch ( comPtr -> command ) { case MACRO: if ( doMacro ( params ) ) { errout ( E_NO_END_MACRO ); } break; case EXPAND: doExpand ( params ); break; default: if ( !doCommand ( comPtr, params ) ) { return 10; } } } else { break; } } close_infile(); close_tempfile(); apply_tempfile ( getPic(), ( argc > 2 ) ? argv[ 2 ] : NULL ); remove_tempfile(); // dumpFigure(); return 0; /* just to suppress the warning */ }
F32 lggBeamMaps::setUpAndGetDuration() { static std::string* settingName = rebind_llcontrol<std::string>("EmeraldBeamShape", &gSavedSettings, true); if(*settingName != lastFileName) { lastFileName = *settingName; if( *settingName != "===OFF===" && *settingName != "") { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beams", "")); std::string path_name2(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "beams", "")); std::string filename = path_name + *settingName + ".xml"; if(gDirUtilp->fileExists(filename)) { }else { filename =path_name2 + *settingName +".xml"; } LLSD mydata = getPic(filename); scale = (F32)mydata["scale"].asReal()/10.0f; LLSD myPicture = mydata["data"]; dots.clear(); for(int i = 0; i < myPicture.size(); i++) { LLSD beamData = myPicture[i]; lggBeamData dot; dot.p = beamData["offset"]; dot.p *= (gSavedSettings.getF32("EmeraldBeamShapeScale")*2.0f); LLColor4 color = beamData["color"]; dot.c = LLColor4U(color); dots.push_back(dot); } F32 maxBPerQS = gSavedSettings.getF32("EmeraldMaxBeamsPerSecond") / 4.0f; duration = llceil((F32)(myPicture.size()) / maxBPerQS) * 0.25f; llinfos << "reading it all now size is " << myPicture.size() << " and duration is " << duration << llendl; }else { dots.clear(); scale = 0.0f;//used as a flag too duration = 0.25f; } } //llinfos << "sent final dur of " << duration << llendl; return duration; }
F32 lggBeamMaps::setUpAndGetDuration() { static LLCachedControl<std::string> settingNameCached(gSavedSettings, "FSBeamShape"); std::string settingName(settingNameCached); if (settingName != mLastFileName) { mLastFileName = settingName; if (!settingName.empty()) { std::string path_name(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "beams", "")); std::string path_name2(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS , "beams", "")); std::string filename = path_name + settingName + ".xml"; if (!gDirUtilp->fileExists(filename)) { filename = path_name2 + settingName + ".xml"; } LLSD mydata = getPic(filename); mScale = (F32)mydata["scale"].asReal() / 10.0f; LLSD myPicture = mydata["data"]; mDots.clear(); for (LLSD::array_iterator it = myPicture.beginArray(); it != myPicture.endArray(); ++it) { LLSD beamData = *it; lggBeamData dot; dot.p = LLVector3d(beamData["offset"]); static LLCachedControl<F32> FSBeamShapeScale(gSavedSettings, "FSBeamShapeScale"); dot.p *= (FSBeamShapeScale * 2.0f); LLColor4 color = LLColor4(beamData["color"]); dot.c = LLColor4U(color); mDots.push_back(dot); } static LLCachedControl<F32> FSMaxBeamsPerSecond(gSavedSettings, "FSMaxBeamsPerSecond"); F32 maxBPerQS = FSMaxBeamsPerSecond / 4.0f; mDuration = llceil((F32)(myPicture.size()) / maxBPerQS) * 0.25f; LL_INFOS("LGG_Beams") << "reading it all now size is " << myPicture.size() << " and duration is " << mDuration << LL_ENDL; } else { mDots.clear(); mScale = 0.0f; //used as a flag too mDuration = 0.25f; } } return mDuration; }
bool VaapiDecoderH265::DPB::initLongTermRef(const PicturePtr& picture, const H265SliceHdr *const slice) { const H265PPS *const pps = slice->pps; const H265SPS *const sps = pps->sps; int32_t deltaPocMsbCycleLt[16]; const int32_t maxPicOrderCntLsb =1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4); uint16_t num = slice->num_long_term_sps + slice->num_long_term_pics; //(7-38) for (int i = 0; i < num; i++) { if( i == 0 || i == slice->num_long_term_sps) deltaPocMsbCycleLt[ i ] = slice->delta_poc_msb_cycle_lt[i]; else deltaPocMsbCycleLt[ i ] = slice->delta_poc_msb_cycle_lt[ i ] + deltaPocMsbCycleLt[i-1]; } //(8-5) for (int i = 0; i < num; i++) { uint16_t poc; bool used; if (i < slice->num_long_term_sps) { poc = sps->lt_ref_pic_poc_lsb_sps[slice->lt_idx_sps[i]]; used = sps->used_by_curr_pic_lt_sps_flag[slice->lt_idx_sps[i]]; } else { poc = slice->poc_lsb_lt[i]; used = slice->used_by_curr_pic_lt_flag[i]; } if (slice->delta_poc_msb_present_flag[i]) { poc += picture->m_poc - deltaPocMsbCycleLt[i] * maxPicOrderCntLsb - slice->pic_order_cnt_lsb; } VaapiDecPictureH265* pic = getPic(poc, slice->delta_poc_msb_present_flag[i]); if (!pic) { ERROR("can't find long ref %d for %d", poc, picture->m_poc); } else { if (used) m_ltCurr.push_back(pic); else m_ltFoll.push_back(pic); } } return true; }
bool VaapiDecoderH265::DPB::initShortTermRef(RefSet& ref, int32_t currPoc, const int32_t* delta, const uint8_t* used, uint8_t num) { if (num > 16) return false; ref.clear(); for (uint8_t i = 0; i < num; i++) { int32_t poc = currPoc + delta[i]; VaapiDecPictureH265* pic = getPic(poc); if (!pic) { ERROR("can't find short ref %d for %d", poc, currPoc); } else { if (used[i]) ref.push_back(pic); else m_stFoll.push_back(pic); } } return true; }
/** Function for mimicking decoder's reference picture buffer management. * \param rcListPic List of picture buffers * \param iGOPSIze Current GOP size * \param iMaxRefPicNum Maximum number of reference pictures allowed * The encoder calls this function to mimic the picture buffer management of the decoder in the function xGetNewPicBuffer. * This will ensure in the encoder that the pictures that does not exist in the decoder will not be used as reference. * TODO: This assumes that the new pics are added at the end of the list. * This needs to be changed for the general case including for the long-term ref pics. * In the future, we should create a single common function for both the encoder and decoder. */ Void TComSlice::decodingMarking( TComList<TComPic*>& rcListPic, Int iGOPSIze, Int& iMaxRefPicNum ) { Int iActualNumOfReference = 0; TComList<TComPic*>::iterator iterPic = rcListPic.begin(); while ( iterPic != rcListPic.end() ) { TComPic* rpcPic = *(iterPic); if ( rpcPic->getSlice( 0 )->isReferenced() ) { if ( rpcPic != getPic() ) { iActualNumOfReference++; } } iterPic++; } // TODO: This assumes that the new pics are added at the end of the list // This needs to be changed for the general case including for the long-term ref pics iMaxRefPicNum = max(iMaxRefPicNum, max(max(2, getNumRefIdx(REF_PIC_LIST_0)+1), iGOPSIze/2 + 2 + getNumRefIdx(REF_PIC_LIST_0))); if ( iActualNumOfReference >= iMaxRefPicNum ) { Int iNumToBeReset = iActualNumOfReference - iMaxRefPicNum + 1; iterPic = rcListPic.begin(); while ( iterPic != rcListPic.end() && iNumToBeReset > 0 ) { TComPic* rpcPic = *(iterPic); if ( rpcPic->getSlice( 0 )->isReferenced() ) { rpcPic->getSlice( 0 )->setReferenced( false ); iNumToBeReset--; } iterPic++; } } }
void DownloadPicture::startDownload() { qDebug() <<"startDownload"; getPic(); }
int beaconpics_main(struct beacon_loc orientation) { int thresh=140; namedWindow("Original 1", WINDOW_NORMAL); namedWindow("Original 2", WINDOW_NORMAL); namedWindow("Original 3", WINDOW_NORMAL); namedWindow("Diff", WINDOW_NORMAL); //hsvParams hsv = {76,0,224,97,37,255}; hsvParams hsv = {20,0,0,97,37,255}; //Set up blob detection parameters SimpleBlobDetector::Params params; // params.blobColor //can we use this??? // params.minDistBetweenBlobs = 50.0f; params.filterByInertia = true; params.filterByConvexity = false; params.filterByColor = false; params.filterByCircularity = false; params.filterByArea = true; params.minThreshold = 150; params.maxThreshold = 255; params.thresholdStep = 1; params.minArea = 0; params.minConvexity = 0.3; params.minInertiaRatio = 0.10; params.maxArea = 2000; params.maxConvexity = 10; vector<KeyPoint> keypoints; VideoCapture cap(0); //capture the video from web cam if ( !cap.isOpened() ) // if not success, exit program { cout << "Cannot open the web cam" << endl; return -1; } while(true) { Mat imgOriginal1 = getPic(cap); Mat imgOriginal2 = getPic(cap); Mat imgOriginal3 = getPic(cap); Mat imgHSV1,imgHSV2, imgHSV3; if(imgOriginal1.empty() || imgOriginal2.empty() || imgOriginal3.empty()) { cout << "can not open " << endl; return -1; } Mat diff; absdiff(imgOriginal1,imgOriginal2,diff); cvtColor(diff, diff, COLOR_BGR2GRAY); //Convert the captured threshold(diff, diff, thresh, 255, cv::THRESH_BINARY); dilate(diff, diff, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) ); //opencv 3.0 version //detect beacon blobs between pictures 1&2 Ptr<SimpleBlobDetector> blobDetect = SimpleBlobDetector::create(params); blobDetect->detect( diff, keypoints ); cout<<keypoints.size()<<endl; //detect blobs between images 2&3 if(keypoints.size() ==0) { absdiff(imgOriginal2,imgOriginal3,diff); cvtColor(diff, diff, COLOR_BGR2GRAY); //Convert the captured threshold(diff, diff, thresh, 255, cv::THRESH_BINARY); dilate(diff, diff, getStructuringElement(MORPH_ELLIPSE, Size(5, 5)) ); blobDetect = SimpleBlobDetector::create(params); blobDetect->detect( diff, keypoints ); } cout<<keypoints.size()<<endl; Mat out; drawKeypoints(diff, keypoints, out, CV_RGB(0,0,0), DrawMatchesFlags::DEFAULT); /*//finding if things are green or red cvtColor(out, out, COLOR_BGR2HSV); inRange(out, Scalar(hsv.hL, hsv.sL, hsv.vL), Scalar(hsv.hH, hsv.sH, hsv.vH), out); blobDetect.detect( out, keypoints ); drawKeypoints(out, keypoints, out, CV_RGB(0,0,0), DrawMatchesFlags::DEFAULT); for(int i=0;i<diff.rows;i++){ for(int j=0;j<diff.cols;j++){ if(out.at<Vec3b>(i,j)[0]==0 && out.at<Vec3b>(i,j)[1]==0 && out.at<Vec3b>(i,j)[2]==0){ imgOriginalON.at<Vec3b>(i,j)=(0,0,0); } } } inRange(imgOriginalON, Scalar(hsv.hL, hsv.sL, hsv.vL), Scalar(hsv.hH, hsv.sH, hsv.vH), out); blobDetect.detect( out, keypoints ); drawKeypoints(out, keypoints, out, CV_RGB(0,0,0), DrawMatchesFlags::DEFAULT); */ //Circle blobs for(int i = 0; i < keypoints.size(); i++) { if(keypoints[i].size>0) circle(out, keypoints[i].pt, 1.5*keypoints[i].size, CV_RGB(0,255,0), 1, 8); } string text; if(keypoints.size() == 4) { text = "Object Found"; cout<<endl<<endl<<"Object Found"<<endl; Point cent; cent=findkeyPoint(keypoints); // cout<<"dist: "<<printDistanceFromLights(keypoints)<<endl; circle(out, cent, 5, CV_RGB(0,100,0), -1, 8); robot_angle(diff, cent.y, cent.x, 1); } else { text = "Error"; cout<<endl<<endl<<"No Object Found"<<endl; // while(keypoints.size() > 2) // thresh+=5; } imshow("Original 1", imgOriginal1); //show the original image imshow("Original 2", imgOriginal2); //show the original image imshow("Original 3", imgOriginal3); //show the original image imshow("Diff", out); waitKey(-1); } return 0; }