void callbackCameraLEFT( const sensor_msgs::ImageConstPtr p_pImageLEFT ) { //ds check if we already have a right frame to compare against if( 0 != g_pImageRIGHTLast ) { //ds only if timestamps match if( g_pImageRIGHTLast->header.stamp == p_pImageLEFT->header.stamp ) { //ds process both images computeDepth( cv_bridge::toCvCopy( p_pImageLEFT, p_pImageLEFT->encoding )->image, cv_bridge::toCvCopy( g_pImageRIGHTLast, g_pImageRIGHTLast->encoding )->image ); //ds reset buffers g_pImageRIGHTLast = 0; g_pImageLEFTLast = 0; } //ds if the timestamp is newer else if( g_pImageRIGHTLast->header.stamp < p_pImageLEFT->header.stamp ) { g_pImageRIGHTLast = 0; g_pImageLEFTLast = p_pImageLEFT; } } else { g_pImageLEFTLast = p_pImageLEFT; } }
void CSwordBookModuleInfo::computeDepth(sword::TreeKeyIdx* key, int level ) { std::string savedKey; // savedKey = key->getFullName(); //sword 1.5.8 savedKey = key->getText(); if (level > m_depth) { m_depth = level; } if (key->hasChildren()) { key->firstChild(); computeDepth(key, level + 1); key->setText( savedKey.c_str() );//return to the initial value } if (key->nextSibling()) { computeDepth(key, level); } }
int CSwordBookModuleInfo::depth() { if (m_depth == -1) { sword::TreeKeyIdx* key = tree(); if (key) { key->root(); computeDepth(key, 0); } } return m_depth; }
t_jit_err jit_tml_fakeDepth_matrix_calc(t_jit_tml_fakeDepth *x, void *inputs, void *outputs) { t_jit_err err=JIT_ERR_NONE; long left_savelock,out_savelock,right_savelock; t_jit_matrix_info left_minfo,right_minfo,out_minfo; long dimcount,planecount; void *left_matrix,*right_matrix, *out_matrix; unsigned char *left_bp, *right_bp, *out_bp; left_matrix = jit_object_method(inputs,_jit_sym_getindex,0); // 1st matrix (left) right_matrix = jit_object_method(inputs,_jit_sym_getindex,1); // 2nd matrix (right) out_matrix = jit_object_method(outputs,_jit_sym_getindex,0); // 1st matrix (depth) if (x && left_matrix && right_matrix && out_matrix) { left_savelock = (long) jit_object_method(left_matrix,_jit_sym_lock,1); right_savelock = (long) jit_object_method(right_matrix,_jit_sym_lock,1); out_savelock = (long) jit_object_method(out_matrix,_jit_sym_lock,1); jit_object_method(left_matrix,_jit_sym_getinfo,&left_minfo); jit_object_method(right_matrix,_jit_sym_getinfo,&right_minfo); jit_object_method(out_matrix,_jit_sym_getinfo,&out_minfo); if (left_minfo.type != right_minfo.type || left_minfo.type != _jit_sym_char) { post("Inputs must of of type _jit_sym_char!"); err = JIT_ERR_MISMATCH_TYPE; goto out; } if (left_minfo.dimcount != 2 || right_minfo.dimcount != 2 || left_minfo.dim[0] != right_minfo.dim[0] || left_minfo.dim[1] != right_minfo.dim[1]) { post("2 dimensions required - both must be the same"); err = JIT_ERR_MISMATCH_DIM; goto out; } if (left_minfo.planecount != 1 || right_minfo.planecount !=1) { post("1 plane needed!"); err = JIT_ERR_MISMATCH_PLANE; goto out; } if (left_minfo.dimcount != out_minfo.dimcount || left_minfo.dim[0] != out_minfo.dim[0] || left_minfo.dim[1] != out_minfo.dim[1] || left_minfo.type != out_minfo.type || left_minfo.planecount != out_minfo.planecount) { out_minfo.dimcount= left_minfo.dimcount; out_minfo.dim[0] = left_minfo.dim[0]; out_minfo.dim[1] = left_minfo.dim[1]; out_minfo.type = left_minfo.type; out_minfo.planecount = left_minfo.planecount; if (jit_object_method(out_matrix, _jit_sym_setinfo, &out_minfo)) { error("Unable to resize output matrix to match input!"); err = JIT_ERR_GENERIC; goto out; } jit_object_method(out_matrix,_jit_sym_getinfo,&out_minfo); } jit_object_method(left_matrix,_jit_sym_getdata,&left_bp); jit_object_method(right_matrix,_jit_sym_getdata,&right_bp); jit_object_method(out_matrix,_jit_sym_getdata,&out_bp); if (!left_bp) { err=JIT_ERR_INVALID_INPUT; goto out;} if (!right_bp) { err=JIT_ERR_INVALID_INPUT; goto out;} if (!out_bp) { err=JIT_ERR_INVALID_OUTPUT; goto out;} //get dimensions/planecount dimcount = out_minfo.dimcount; planecount = out_minfo.planecount; computeDepth(x->d, left_bp, left_minfo.dim[0], left_minfo.dim[1], left_minfo.dimstride[0], left_minfo.dimstride[1], right_bp, right_minfo.dimstride[0], right_minfo.dimstride[1], out_bp, out_minfo.dimstride[0], out_minfo.dimstride[1]); } else { return JIT_ERR_INVALID_PTR; } out: jit_object_method(out_matrix,_jit_sym_lock,out_savelock); jit_object_method(left_matrix,_jit_sym_lock,left_savelock); jit_object_method(right_matrix,_jit_sym_lock,right_savelock); return err; }
// returns false if tree had problem, true otherwise bool TopTree::checkTree ( bool printMsgs ) { // now check parent kid correlations for ( int32_t i = 0 ; i < m_numUsedNodes ; i++ ) { // skip node if parents is -2 (unoccupied) if ( PARENT(i) == -2 ) continue; // if no left/right kid it MUST be -1 if ( LEFT(i) < -1 ) return log("query: toptree: checktree: left " "kid %"INT32" < -1",i); if ( RIGHT(i) < -1 ) return log("query: toptree: checktree: right " "kid %"INT32" < -1",i); // check left kid if ( LEFT(i) >= 0 && PARENT(LEFT(i)) != i ) return log("query: toptree: checktree: tree has " "error %"INT32"",i); // then right kid if ( RIGHT(i) >= 0 && PARENT(RIGHT(i)) != i ) return log("query: toptree: checktree: tree has " "error2 %"INT32"",i); } // now return if we aren't doing active balancing //if ( ! DEPTH ) return true; // debug -- just always return now if ( printMsgs ) log("***m_headNode=%"INT32", m_numUsedNodes=%"INT32"", m_headNode,m_numUsedNodes); // verify that parent links correspond to kids for ( int32_t i = 0 ; i < m_numUsedNodes ; i++ ) { int32_t P = PARENT (i); if ( P == -2 ) continue; // deleted node if ( P == -1 && i != m_headNode ) return log("query: toptree: checktree: node %"INT32" has " "no parent",i); // check kids if ( P>=0 && LEFT(P) != i && RIGHT(P) != i ) return log("query: toptree: checktree: node %"INT32"'s " "parent disowned",i); // ensure i goes back to head node int32_t j = i; while ( j >= 0 ) { if ( j == m_headNode ) break; j = PARENT(j); } if ( j != m_headNode ) return log("query: toptree: checktree: node %"INT32"'s no " "head node above",i); if ( printMsgs ) fprintf(stderr,"***node=%"INT32" left=%"INT32" rght=%"INT32" " "prnt=%"INT32", depth=%"INT32"\n", i,LEFT(i),RIGHT(i),PARENT(i), (int32_t)DEPTH(i)); //ensure depth int32_t newDepth = computeDepth ( i ); if ( DEPTH(i) != newDepth ) return log("query: toptree: checktree: node %"INT32"'s " "depth should be %"INT32"",i,newDepth); } if ( printMsgs ) log("query: ---------------"); // no problems found return true; }
static void convertPage(FILE * const ifP, int const turnflag, int const turnokflag, bool const psfilter, bool const rle, bool const flate, bool const ascii85, bool const setpage, bool const showpage, bool const center, float const scale, int const dpiX, int const dpiY, int const pagewid, int const pagehgt, int const imagewidth, int const imageheight, bool const equalpixels, char const name[], bool const dict, bool const vmreclaim, bool const levelIsGiven, bool const levelGiven) { struct pam inpam; tuple* tuplerow; unsigned int padright; /* Number of bits we must add to the right end of each Postscript output line in order to have an integral number of bytes of output. E.g. at 2 bits per sample with 10 columns, this would be 4. */ int row; unsigned int ps_maxval; /* The maxval of the Postscript program */ float scols, srows; float llx, lly; bool turned; bool color; unsigned int postscriptLevel; struct bmepsoe * bmepsoeP; pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type)); if (!STRSEQ(inpam.tuple_type, PAM_PBM_TUPLETYPE) && !STRSEQ(inpam.tuple_type, PAM_PGM_TUPLETYPE) && !STRSEQ(inpam.tuple_type, PAM_PPM_TUPLETYPE)) pm_error("Unrecognized tuple type %s. This program accepts only " "PBM, PGM, PPM, and equivalent PAM input images", inpam.tuple_type); color = STRSEQ(inpam.tuple_type, PAM_PPM_TUPLETYPE); selectPostscriptLevel(levelIsGiven, levelGiven, color, dict, flate, ascii85, &postscriptLevel); if (color) pm_message("generating color Postscript program."); computeDepth(inpam.maxval, &bitspersample, &ps_maxval); { unsigned int const realBitsPerLine = inpam.width * bitspersample; unsigned int const paddedBitsPerLine = ((realBitsPerLine + 7) / 8) * 8; padright = (paddedBitsPerLine - realBitsPerLine) / bitspersample; } /* In positioning/scaling the image, we treat the input image as if it has a density of 72 pixels per inch. */ computeImagePosition(dpiX, dpiY, inpam.width, inpam.height, turnflag, turnokflag, center, pagewid, pagehgt, scale, imagewidth, imageheight, equalpixels, &scols, &srows, &llx, &lly, &turned); putinit(postscriptLevel, name, inpam.width, inpam.height, scols, srows, llx, lly, padright, bitspersample, pagewid, pagehgt, color, turned, rle, flate, ascii85, setpage, psfilter, dict); createBmepsOutputEncoder(&bmepsoeP, stdout, rle, flate, ascii85); initNativeOutputEncoder(rle, bitspersample); tuplerow = pnm_allocpamrow(&inpam); for (row = 0; row < inpam.height; ++row) { pnm_readpamrow(&inpam, tuplerow); if (psfilter) convertRowPsFilter(&inpam, tuplerow, bmepsoeP); else convertRowNative(&inpam, tuplerow, ps_maxval, rle, padright); } pnm_freepamrow(tuplerow); if (psfilter) flushBmepsOutput(bmepsoeP); else flushNativeOutput(rle); destroyBmepsOutputEncoder(bmepsoeP); putEnd(showpage, psfilter, ascii85, dict, vmreclaim); }