void _ROITracker::track(void) { Frame* pFrame; Mat* pMat; NULL_(m_pStream); CHECK_(!m_bTracking); CHECK_(m_pTracker.empty()); pFrame = m_pStream->bgr(); NULL_(pFrame); CHECK_(!pFrame->isNewerThan(m_pFrame)); m_pFrame->update(pFrame); pMat = m_pFrame->getCMat(); if (pMat->empty()) return; if (m_newROI.width > 0) { m_pTracker.release(); m_pTracker = Tracker::create("KCF"); m_ROI = m_newROI; m_pTracker->init(*pMat, m_ROI); m_newROI.width = 0; } // update the tracking result m_pTracker->update(*pMat, m_ROI); }
VerificationType VerificationType::get_component(ClassVerifier *context, TRAPS) const { assert(is_array() && name()->utf8_length() >= 2, "Must be a valid array"); Symbol* component; switch (name()->byte_at(1)) { case 'Z': return VerificationType(Boolean); case 'B': return VerificationType(Byte); case 'C': return VerificationType(Char); case 'S': return VerificationType(Short); case 'I': return VerificationType(Integer); case 'J': return VerificationType(Long); case 'F': return VerificationType(Float); case 'D': return VerificationType(Double); case '[': component = context->create_temporary_symbol( name(), 1, name()->utf8_length(), CHECK_(VerificationType::bogus_type())); return VerificationType::reference_type(component); case 'L': component = context->create_temporary_symbol( name(), 2, name()->utf8_length() - 1, CHECK_(VerificationType::bogus_type())); return VerificationType::reference_type(component); default: // Met an invalid type signature, e.g. [X return VerificationType::bogus_type(); } }
methodHandle Bytecode_invoke::static_target(TRAPS) { methodHandle m; KlassHandle resolved_klass; constantPoolHandle constants(THREAD, _method->constants()); if (adjusted_invoke_code() != Bytecodes::_invokeinterface) { LinkResolver::resolve_method(m, resolved_klass, constants, index(), CHECK_(methodHandle())); } else { LinkResolver::resolve_interface_method(m, resolved_klass, constants, index(), CHECK_(methodHandle())); } return m; }
VerificationType StackMapFrame::set_locals_from_arg( const methodHandle m, VerificationType thisKlass, TRAPS) { SignatureStream ss(m->signature()); int init_local_num = 0; if (!m->is_static()) { init_local_num++; // add one extra argument for instance method if (m->name() == vmSymbols::object_initializer_name() && thisKlass.name() != vmSymbols::java_lang_Object()) { _locals[0] = VerificationType::uninitialized_this_type(); _flags |= FLAG_THIS_UNINIT; } else { _locals[0] = thisKlass; } } // local num may be greater than size of parameters because long/double occupies two slots while(!ss.at_return_type()) { init_local_num += _verifier->change_sig_to_verificationType( &ss, &_locals[init_local_num], CHECK_VERIFY_(verifier(), VerificationType::bogus_type())); ss.next(); } _locals_size = init_local_num; switch (ss.type()) { case T_OBJECT: case T_ARRAY: { Symbol* sig = ss.as_symbol(CHECK_(VerificationType::bogus_type())); // Create another symbol to save as signature stream unreferences // this symbol. Symbol* sig_copy = verifier()->create_temporary_symbol(sig, 0, sig->utf8_length(), CHECK_(VerificationType::bogus_type())); assert(sig_copy == sig, "symbols don't match"); return VerificationType::reference_type(sig_copy); } case T_INT: return VerificationType::integer_type(); case T_BYTE: return VerificationType::byte_type(); case T_CHAR: return VerificationType::char_type(); case T_SHORT: return VerificationType::short_type(); case T_BOOLEAN: return VerificationType::boolean_type(); case T_FLOAT: return VerificationType::float_type(); case T_DOUBLE: return VerificationType::double_type(); case T_LONG: return VerificationType::long_type(); case T_VOID: return VerificationType::bogus_type(); default: ShouldNotReachHere(); } return VerificationType::bogus_type(); }
objArrayHandle LiveFrameStream::values_to_object_array(StackValueCollection* values, TRAPS) { objArrayHandle empty; int length = values->size(); objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(), length, CHECK_(empty)); objArrayHandle array_h(THREAD, array_oop); for (int i = 0; i < values->size(); i++) { StackValue* st = values->at(i); oop obj = create_primitive_value_instance(values, i, CHECK_(empty)); if (obj != NULL) array_h->obj_at_put(i, obj); } return array_h; }
// size is the new size of the instruction at bci. Hence, if size is less than the current // instruction sice, we will shrink the code. methodHandle Relocator::insert_space_at(int bci, int size, u_char inst_buffer[], TRAPS) { _changes = new GrowableArray<ChangeItem*> (10); _changes->push(new ChangeWiden(bci, size, inst_buffer)); if (TraceRelocator) { tty->print_cr("Space at: %d Size: %d", bci, size); _method->print(); _method->print_codes(); tty->print_cr("-------------------------------------------------"); } if (!handle_code_changes()) return methodHandle(); // Construct the new method methodHandle new_method = Method::clone_with_new_data(method(), code_array(), code_length(), compressed_line_number_table(), compressed_line_number_table_size(), CHECK_(methodHandle())); // Deallocate the old Method* from metadata ClassLoaderData* loader_data = method()->method_holder()->class_loader_data(); loader_data->add_to_deallocate_list(method()()); set_method(new_method); if (TraceRelocator) { tty->print_cr("-------------------------------------------------"); tty->print_cr("new method"); _method->print_codes(); } return new_method; }
// size is the new size of the instruction at bci. Hence, if size is less than the current // instruction sice, we will shrink the code. methodHandle Relocator::insert_space_at(int bci, int size, u_char inst_buffer[], TRAPS) { _changes = new GrowableArray<ChangeItem*> (10); _changes->push(new ChangeWiden(bci, size, inst_buffer)); if (TraceRelocator) { tty->print_cr("Space at: %d Size: %d", bci, size); _method->print(); _method->print_codes(); tty->print_cr("-------------------------------------------------"); } if (!handle_code_changes()) return methodHandle(); // Construct the new method methodHandle new_method = methodOopDesc::clone_with_new_data(method(), code_array(), code_length(), compressed_line_number_table(), compressed_line_number_table_size(), CHECK_(methodHandle())); set_method(new_method); if (TraceRelocator) { tty->print_cr("-------------------------------------------------"); tty->print_cr("new method"); _method->print_codes(); } return new_method; }
arrayKlassHandle arrayKlass::base_create_array_klass( const Klass_vtbl& cplusplus_vtbl, int header_size, KlassHandle klass, TRAPS) { // Allocation // Note: because the Java vtable must start at the same offset in all klasses, // we must insert filler fields into arrayKlass to make it the same size as instanceKlass. // If this assert fails, add filler to instanceKlass to make it bigger. assert(header_size <= instanceKlass::header_size(), "array klasses must be same size as instanceKlass"); header_size = instanceKlass::header_size(); // Arrays don't add any new methods, so their vtable is the same size as // the vtable of klass Object. int vtable_size = Universe::base_vtable_size(); arrayKlassHandle k; KlassHandle base_klass = Klass::base_create_klass(klass, header_size + vtable_size, cplusplus_vtbl, CHECK_(k)); k = arrayKlassHandle(THREAD, base_klass()); assert(!k()->is_parsable(), "not expecting parsability yet."); k->set_super(Universe::is_bootstrapping() ? NULL : SystemDictionary::object_klass()); k->set_size_helper(0); k->set_dimension(1); k->set_higher_dimension(NULL); k->set_lower_dimension(NULL); k->set_vtable_length(vtable_size); k->set_is_cloneable(); // All arrays are considered to be cloneable (See JLS 20.1.5) assert(k()->is_parsable(), "should be parsable here."); // Make sure size calculation is right assert(k()->size() == align_object_size(header_size + vtable_size), "wrong size for object"); return k; }
objArrayHandle LiveFrameStream::monitors_to_object_array(GrowableArray<MonitorInfo*>* monitors, TRAPS) { int length = monitors->length(); objArrayOop array_oop = oopFactory::new_objArray(SystemDictionary::Object_klass(), length, CHECK_(objArrayHandle())); objArrayHandle array_h(THREAD, array_oop); for (int i = 0; i < length; i++) { MonitorInfo* monitor = monitors->at(i); array_h->obj_at_put(i, monitor->owner()); } return array_h; }
void _Lightware_SF40_sender::MBS(uint8_t MBS) { NULL_(m_pSerialPort); CHECK_(!m_pSerialPort->isOpen()); if(MBS>3)MBS = 3; char str[32]; sprintf(str, "#MBS,%d\x0d\x0a", MBS); m_pSerialPort->write((uint8_t*)str, strlen(str)); }
void _Bullseye::detectCircleHough(void) { if(!m_pStream)return; Frame* pFrame = m_pStream->hsv(); NULL_(pFrame); CHECK_(pFrame->empty()); if(!pFrame->isNewerThan(m_pFrame))return; m_pFrame->update(pFrame); // cv::Mat bgr_image = *m_pFrame->getCMat(); // cv::medianBlur(bgr_image, bgr_image, m_kSize); // Convert input image to HSV // cv::Mat hsv_image; // cv::cvtColor(bgr_image, hsv_image, cv::COLOR_BGR2HSV); // Convert input image to HSV cv::Mat hsv_image = *m_pFrame->getCMat(); // cv::medianBlur(hsv_image, hsv_image, 3); // Threshold the HSV image, keep only the red pixels cv::Mat lower_red_hue_range; cv::Mat upper_red_hue_range; cv::inRange(hsv_image, cv::Scalar(0, 100, 100), cv::Scalar(10, 255, 255), lower_red_hue_range); cv::inRange(hsv_image, cv::Scalar(160, 100, 100), cv::Scalar(179, 255, 255), upper_red_hue_range); // Combine the above two images cv::Mat red_hue_image; cv::addWeighted(lower_red_hue_range, 1.0, upper_red_hue_range, 1.0, 0.0, red_hue_image); cv::GaussianBlur(red_hue_image, red_hue_image, cv::Size(9, 9), 2, 2); // Use the Hough transform to detect circles in the combined threshold image std::vector<cv::Vec3f> circles; cv::HoughCircles(red_hue_image, circles, CV_HOUGH_GRADIENT, 1, m_houghMinDist, m_houghParam1, m_houghParam2, m_houghMinR, m_houghMaxR); m_numCircle = 0; if(circles.size() == 0)return; for(size_t current_circle = 0; current_circle < circles.size(); ++current_circle) { m_pCircle[m_numCircle].m_x = circles[current_circle][0]; m_pCircle[m_numCircle].m_y = circles[current_circle][1]; m_pCircle[m_numCircle].m_z = circles[current_circle][2]; m_numCircle++; if (m_numCircle == NUM_MARKER) { break; } } }
// Pop and return the top type on stack type array after verifying it // is assignable to type. inline VerificationType pop_stack(VerificationType type, TRAPS) { if (_stack_size != 0) { VerificationType top = _stack[_stack_size - 1]; bool subtype = type.is_assignable_from( top, verifier(), CHECK_(VerificationType::bogus_type())); if (subtype) { --_stack_size; return top; } } return pop_stack_ex(type, THREAD); }
void APMrover_base::sendHeartbeat(void) { NULL_(m_pMavlink); //Sending Heartbeat at 1Hz uint64_t timeNow = get_time_usec(); CHECK_(timeNow - m_lastHeartbeat < USEC_1SEC); m_pMavlink->sendHeartbeat(); m_lastHeartbeat = timeNow; LOG(INFO)<<"APMrover HEARTBEAT:"<<++m_iHeartbeat; }
BasicType FieldType::get_array_info(symbolOop signature, jint* dimension, symbolOop* object_key, TRAPS) { assert(basic_type(signature) == T_ARRAY, "must be array"); int index = 1; int dim = 1; skip_optional_size(signature, &index); while (signature->byte_at(index) == '[') { index++; dim++; skip_optional_size(signature, &index); } ResourceMark rm; symbolOop element = oopFactory::new_symbol(signature->as_C_string() + index, CHECK_(T_BYTE)); BasicType element_type = FieldType::basic_type(element); if (element_type == T_OBJECT) { char* object_type = element->as_C_string(); object_type[element->utf8_length() - 1] = '\0'; *object_key = oopFactory::new_symbol(object_type + 1, CHECK_(T_BYTE)); } // Pass dimension back to caller *dimension = dim; return element_type; }
VerificationType StackMapFrame::pop_stack_ex(VerificationType type, TRAPS) { if (_stack_size <= 0) { verifier()->verify_error(_offset, "Operand stack underflow"); return VerificationType::bogus_type(); } VerificationType top = _stack[--_stack_size]; bool subtype = type.is_assignable_from( top, verifier()->current_class(), CHECK_(VerificationType::bogus_type())); if (!subtype) { verifier()->verify_error(_offset, "Bad type on operand stack"); return VerificationType::bogus_type(); } NOT_PRODUCT( _stack[_stack_size] = VerificationType::bogus_type(); ) return top;
void APMrover_base::sendHeartbeat(void) { NULL_(m_pMavlink); //Sending Heartbeat at 1Hz uint64_t timeNow = get_time_usec(); CHECK_(timeNow - m_lastHeartbeat < USEC_1SEC); m_pMavlink->sendHeartbeat(); m_lastHeartbeat = timeNow; #ifdef MAVLINK_DEBUG printf("<- OpenKAI HEARTBEAT:%d\n", (++m_iHeartbeat)); #endif }
void _Lightware_SF40_sender::LD(void) { NULL_(m_pSerialPort); CHECK_(!m_pSerialPort->isOpen()); //?LD,aaa.a<CR><LF> <space>dd.dd<CR><LF> char str[128]; for(double angle=0; angle<DEG_AROUND; angle+=m_dAngle) { sprintf(str, "?LD,%.1f\x0d\x0a", angle); m_pSerialPort->write((uint8_t*)str, strlen(str)); } }
void _SSD::detectFrame(void) { OBJECT obj; Frame* pFrame; unsigned int iClass; unsigned int i; NULL_(m_pStream); NULL_(m_pUniverse); pFrame = m_pStream->bgr(); NULL_(pFrame); CHECK_(pFrame->empty()); if (!pFrame->isNewerThan(m_pFrame))return; m_pFrame->update(pFrame); cv::cuda::GpuMat* pImg = m_pFrame->getGMat(); std::vector<vector<float> > detections = detect(m_pFrame); /* Print the detection results. */ for (i = 0; i < detections.size(); ++i) { const vector<float>& d = detections[i]; // Detection format: [image_id, label, score, xmin, ymin, xmax, ymax]. // CHECK_EQ(d.size(), 7); // float size = d.size(); const float score = d[2]; if (score < m_confidence_threshold)continue; iClass = static_cast<int>(d[1])-1; if(iClass >= labels_.size())continue; obj.m_iClass = iClass; obj.m_bbox.m_x = d[3] * pImg->cols; obj.m_bbox.m_y = d[4] * pImg->rows; obj.m_bbox.m_z = d[5] * pImg->cols; obj.m_bbox.m_w = d[6] * pImg->rows; obj.m_camSize.m_x = pImg->cols; obj.m_camSize.m_y = pImg->rows; obj.m_dist = 0.0; obj.m_prob = 0.0; m_pUniverse->addObject(&obj); } }
VerificationType StackMapFrame::pop_stack_ex(VerificationType type, TRAPS) { if (_stack_size <= 0) { verifier()->verify_error( ErrorContext::stack_underflow(_offset, this), "Operand stack underflow"); return VerificationType::bogus_type(); } VerificationType top = _stack[--_stack_size]; bool subtype = type.is_assignable_from( top, verifier(), CHECK_(VerificationType::bogus_type())); if (!subtype) { verifier()->verify_error( ErrorContext::bad_type(_offset, stack_top_ctx(), TypeOrigin::implicit(type)), "Bad type on operand stack"); return VerificationType::bogus_type(); } return top; }
VerificationType StackMapFrame::get_local( int32_t index, VerificationType type, TRAPS) { if (index >= _max_locals) { verifier()->verify_error( ErrorContext::bad_local_index(_offset, index), "Local variable table overflow"); return VerificationType::bogus_type(); } bool subtype = type.is_assignable_from(_locals[index], verifier(), CHECK_(VerificationType::bogus_type())); if (!subtype) { verifier()->verify_error( ErrorContext::bad_type(_offset, TypeOrigin::local(index, this), TypeOrigin::implicit(type)), "Bad local variable type"); return VerificationType::bogus_type(); } if(index >= _locals_size) { _locals_size = index + 1; } return _locals[index]; }
// After constant pool is created, revisit methods containing jsrs. methodHandle Rewriter::rewrite_jsrs(methodHandle method, TRAPS) { ResolveOopMapConflicts romc(method); methodHandle original_method = method; method = romc.do_potential_rewrite(CHECK_(methodHandle())); if (method() != original_method()) { // Insert invalid bytecode into original methodOop and set // interpreter entrypoint, so that a executing this method // will manifest itself in an easy recognizable form. address bcp = original_method->bcp_from(0); *bcp = (u1)Bytecodes::_shouldnotreachhere; int kind = Interpreter::method_kind(original_method); original_method->set_interpreter_kind(kind); } // Update monitor matching info. if (romc.monitor_safe()) { method->set_guaranteed_monitor_matching(); } return method; }
void HM_follow::update(void) { this->ActionBase::update(); NULL_(m_pHM); NULL_(m_pUniv); CHECK_(m_pAM->getCurrentStateIdx() != m_iActiveState); //get visual target and decide motion m_pTarget = m_pUniv->getObjectByClass(m_targetClass); if (m_pTarget == NULL) { //no target found, stop and standby TODO: go back to work m_pHM->m_motorPwmL = 0; m_pHM->m_motorPwmR = 0; m_pHM->m_bSpeaker = false; } else { m_pTargetX->input(m_pTarget->m_bbox.midX()); m_pTargetY->input(m_pTarget->m_bbox.midY()); m_pTargetArea->input(m_pTarget->m_bbox.area()); //forward or backward int rpmSpeed = (m_destArea*m_pTarget->m_camSize.area() - m_pTargetArea->v()) * m_speedP; //steering int rpmSteer = (m_destX*m_pTarget->m_camSize.m_x - m_pTargetX->v()) * m_steerP; m_pHM->m_motorPwmL = rpmSpeed - rpmSteer; m_pHM->m_motorPwmR = rpmSpeed + rpmSteer; m_pHM->m_bSpeaker = true; } m_pHM->updateCAN(); }
void RC_visualFollow::update(void) { this->ActionBase::update(); NULL_(m_pRC); NULL_(m_pROITracker); CHECK_(m_pAM->getCurrentStateIdx() != m_iActiveState); if (m_pROITracker->m_bTracking == false) { m_pRCconfig->m_rcRoll.neutral(); m_pRCconfig->m_rcPitch.neutral(); m_roll.resetErr(); m_pitch.resetErr(); // m_pCtrl->m_pRC->rc_overide(m_pCtrl->m_nRC, m_pCtrl->m_pRC); return; } double posRoll; double posPitch; double ovDTime; RC_PID* pidRoll = &m_pRCconfig->m_pidRoll; RC_PID* pidPitch = &m_pRCconfig->m_pidPitch; RC_PID* pidAlt = &m_pRCconfig->m_pidAlt; RC_PID* pidYaw = &m_pRCconfig->m_pidYaw; RC_CHANNEL* pRCroll = &m_pRCconfig->m_rcRoll; RC_CHANNEL* pRCpitch = &m_pRCconfig->m_rcPitch; RC_CHANNEL* pRCalt = &m_pRCconfig->m_rcAlt; RC_CHANNEL* pRCyaw = &m_pRCconfig->m_rcYaw; ovDTime = (1.0 / m_pROITracker->m_dTime) * 1000; //ms posRoll = m_roll.m_pos; posPitch = m_pitch.m_pos; //Update pos from ROI tracker m_roll.m_pos = m_pROITracker->m_ROI.x + m_pROITracker->m_ROI.width * 0.5; m_pitch.m_pos = m_pROITracker->m_ROI.y + m_pROITracker->m_ROI.height * 0.5; //Update current position with trajectory estimation posRoll = m_roll.m_pos + (m_roll.m_pos - posRoll) * pidRoll->m_dT * ovDTime; posPitch = m_pitch.m_pos + (m_pitch.m_pos - posPitch) * pidPitch->m_dT * ovDTime; //Roll m_roll.m_errOld = m_roll.m_err; m_roll.m_err = m_roll.m_targetPos - posRoll; m_roll.m_errInteg += m_roll.m_err; pRCroll->m_pwm = pRCroll->m_pwmN + pidRoll->m_P * m_roll.m_err + pidRoll->m_D * (m_roll.m_err - m_roll.m_errOld) * ovDTime + constrain(pidRoll->m_I * m_roll.m_errInteg, pidRoll->m_Imax, -pidRoll->m_Imax); pRCroll->m_pwm = constrain(pRCroll->m_pwm, pRCroll->m_pwmL, pRCroll->m_pwmH); //Pitch m_pitch.m_errOld = m_pitch.m_err; m_pitch.m_err = m_pitch.m_targetPos - posPitch; m_pitch.m_errInteg += m_pitch.m_err; pRCpitch->m_pwm = pRCpitch->m_pwmN + pidPitch->m_P * m_pitch.m_err + pidPitch->m_D * (m_pitch.m_err - m_pitch.m_errOld) * ovDTime + constrain(pidPitch->m_I * m_pitch.m_errInteg, pidPitch->m_Imax, -pidPitch->m_Imax); pRCpitch->m_pwm = constrain(pRCpitch->m_pwm, pRCpitch->m_pwmL, pRCpitch->m_pwmH); //RC output // m_pCtrl->m_pRC->rc_overide(m_pCtrl->m_nRC, m_pCtrl->m_pRC); return; }
void RC_visualFollow::onMouseAssist(MOUSE* pMouse, BUTTON* pBtn) { NULL_(pMouse); Rect2d roi; int ROIhalf; switch (pMouse->m_event) { case EVENT_LBUTTONDOWN: if (!pBtn) { ROIhalf = m_ROIsize / 2; m_ROI.m_x = pMouse->m_x - ROIhalf; m_ROI.m_y = pMouse->m_y - ROIhalf; m_ROI.m_z = pMouse->m_x + ROIhalf; m_ROI.m_w = pMouse->m_y + ROIhalf; roi = getMouseROI(m_ROI); m_pROITracker->setROI(roi); m_pROITracker->tracking(true); m_bSelect = true; return; } if (pBtn->m_name == "CLR") { //Clear ROI m_pROITracker->tracking(false); m_bSelect = false; return; } if (pBtn->m_name == "+") { //Magnify the ROI size m_bSelect = false; CHECK_(m_ROIsize >= m_ROIsizeTo); m_ROIsize += m_ROIsizeStep; CHECK_(!m_pROITracker->m_bTracking); roi.x = m_pROITracker->m_ROI.x + m_pROITracker->m_ROI.width / 2; roi.y = m_pROITracker->m_ROI.y + m_pROITracker->m_ROI.height / 2; ROIhalf = m_ROIsize / 2; m_ROI.m_x = roi.x - ROIhalf; m_ROI.m_y = roi.y - ROIhalf; m_ROI.m_z = roi.x + ROIhalf; m_ROI.m_w = roi.y + ROIhalf; roi = getMouseROI(m_ROI); m_pROITracker->setROI(roi); return; } if (pBtn->m_name == "-") { //Shrink the ROI size m_bSelect = false; CHECK_(m_ROIsize <= m_ROIsizeFrom); m_ROIsize -= m_ROIsizeStep; CHECK_(!m_pROITracker->m_bTracking); roi.x = m_pROITracker->m_ROI.x + m_pROITracker->m_ROI.width / 2; roi.y = m_pROITracker->m_ROI.y + m_pROITracker->m_ROI.height / 2; ROIhalf = m_ROIsize / 2; m_ROI.m_x = roi.x - ROIhalf; m_ROI.m_y = roi.y - ROIhalf; m_ROI.m_z = roi.x + ROIhalf; m_ROI.m_w = roi.y + ROIhalf; roi = getMouseROI(m_ROI); m_pROITracker->setROI(roi); return; } if (pBtn->m_name == "MODE") { m_ROI.m_x = 0; m_ROI.m_y = 0; m_ROI.m_z = 0; m_ROI.m_w = 0; m_pROITracker->tracking(false); m_bSelect = false; m_ROImode = MODE_DRAWRECT; return; } break; case EVENT_MOUSEMOVE: CHECK_(!m_bSelect); ROIhalf = m_ROIsize / 2; m_ROI.m_x = pMouse->m_x - ROIhalf; m_ROI.m_y = pMouse->m_y - ROIhalf; m_ROI.m_z = pMouse->m_x + ROIhalf; m_ROI.m_w = pMouse->m_y + ROIhalf; roi = getMouseROI(m_ROI); m_pROITracker->setROI(roi); m_pROITracker->tracking(true); break; case EVENT_LBUTTONUP: m_bSelect = false; break; case EVENT_RBUTTONDOWN: break; default: break; } }
void _BgFg::detect(void) { int i; Point2f center; float radius; vector< vector< Point > > contours; vector<Vec3f> circles; UMat matThresh; Frame* pRGB; if(!m_pCamStream)return; pRGB = m_pCamStream->bgr();//m_pCamStream->m_pFrameL; NULL_(pRGB); CHECK_(pRGB->empty()); m_pBgSubtractor->apply(*pRGB->getGMat(), m_gFg); // m_pBgSubtractor->getBackgroundImage(m_gBg); pRGB->getGMat()->download(m_Mat); m_gFg.download(matThresh); //Find the contours findContours(matThresh, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); // drawContours(m_Mat, contours, -1, Scalar(0, 255, 0), 2); //Find marker m_numAllMarker = 0; for (i=0; i<contours.size(); i++) { minEnclosingCircle(contours[i], center, radius); // circle(m_Mat, center, radius, Scalar(0, 255, 0), 1); //New marker found if (contourArea(contours[i]) < 10)continue; if (radius < m_minSize)continue; circle(m_Mat, center, radius, Scalar(0, 255, 0), 2); m_pAllMarker[m_numAllMarker].m_x = center.x; m_pAllMarker[m_numAllMarker].m_y = center.y; m_pAllMarker[m_numAllMarker].m_z = radius; m_pAllMarker[m_numAllMarker].m_w = abs(center.x - m_objROIPos.m_x) + abs(center.y - m_objROIPos.m_y); m_numAllMarker++; if (m_numAllMarker == NUM_MARKER) { break; } } //Failed to detect any marker if (m_numAllMarker <= 0) { m_objLockLevel = LOCK_LEVEL_NONE; return; } //TODO: use the center point of all points as the vehicle position //Sorting the markers from near to far // for (i=1; i<m_numAllMarker; i++) // { // for (j=i-1; j>=0; j--) // { // if (m_pAllMarker[j+1].m_w > m_pAllMarker[j].m_w) // { // break; // } // // v4tmp = m_pAllMarker[j]; // m_pAllMarker[j] = m_pAllMarker[j+1]; // m_pAllMarker[j+1] = v4tmp; // } // } m_objPos.m_x = m_pAllMarker[0].m_x; m_objPos.m_y = m_pAllMarker[0].m_y; m_objPos.m_z = m_pAllMarker[0].m_z; m_objROIPos = m_objPos; //only position is locked m_objLockLevel = LOCK_LEVEL_POS; //Determine the center position and size of object /* m_objPos.m_x = (m_pAllMarker[1].m_x + m_pAllMarker[0].m_x)*0.5; m_objPos.m_y = (m_pAllMarker[1].m_y + m_pAllMarker[0].m_y)*0.5; m_objPos.m_z = abs(m_pAllMarker[1].m_x - m_pAllMarker[0].m_x); m_objROIPos = m_objPos; m_objLockLevel = LOCK_LEVEL_SIZE; m_objLockLevel = LOCK_LEVEL_ATT; */ }
// Update child's copy of super vtable for overrides // OR return true if a new vtable entry is required // Only called for instanceKlass's, i.e. not for arrays // If that changed, could not use _klass as handle for klass bool klassVtable::update_inherited_vtable(instanceKlass* klass, methodHandle target_method, int super_vtable_len, bool checkconstraints, TRAPS) { ResourceMark rm; bool allocate_new = true; assert(klass->oop_is_instance(), "must be instanceKlass"); // Initialize the method's vtable index to "nonvirtual". // If we allocate a vtable entry, we will update it to a non-negative number. target_method()->set_vtable_index(methodOopDesc::nonvirtual_vtable_index); // Static and <init> methods are never in if (target_method()->is_static() || target_method()->name() == vmSymbols::object_initializer_name()) { return false; } if (klass->is_final() || target_method()->is_final()) { // a final method never needs a new entry; final methods can be statically // resolved and they have to be present in the vtable only if they override // a super's method, in which case they re-use its entry allocate_new = false; } // we need a new entry if there is no superclass if (klass->super() == NULL) { return allocate_new; } // private methods always have a new entry in the vtable // specification interpretation since classic has // private methods not overriding if (target_method()->is_private()) { return allocate_new; } // search through the vtable and update overridden entries // Since check_signature_loaders acquires SystemDictionary_lock // which can block for gc, once we are in this loop, use handles // For classfiles built with >= jdk7, we now look for transitive overrides Symbol* name = target_method()->name(); Symbol* signature = target_method()->signature(); Handle target_loader(THREAD, _klass->class_loader()); Symbol* target_classname = _klass->name(); for(int i = 0; i < super_vtable_len; i++) { methodOop super_method = method_at(i); // Check if method name matches if (super_method->name() == name && super_method->signature() == signature) { // get super_klass for method_holder for the found method instanceKlass* super_klass = instanceKlass::cast(super_method->method_holder()); if ((super_klass->is_override(super_method, target_loader, target_classname, THREAD)) || ((klass->major_version() >= VTABLE_TRANSITIVE_OVERRIDE_VERSION) && ((super_klass = find_transitive_override(super_klass, target_method, i, target_loader, target_classname, THREAD)) != (instanceKlass*)NULL))) { // overriding, so no new entry allocate_new = false; if (checkconstraints) { // Override vtable entry if passes loader constraint check // if loader constraint checking requested // No need to visit his super, since he and his super // have already made any needed loader constraints. // Since loader constraints are transitive, it is enough // to link to the first super, and we get all the others. Handle super_loader(THREAD, super_klass->class_loader()); if (target_loader() != super_loader()) { ResourceMark rm(THREAD); char* failed_type_name = SystemDictionary::check_signature_loaders(signature, target_loader, super_loader, true, CHECK_(false)); if (failed_type_name != NULL) { const char* msg = "loader constraint violation: when resolving " "overridden method \"%s\" the class loader (instance" " of %s) of the current class, %s, and its superclass loader " "(instance of %s), have different Class objects for the type " "%s used in the signature"; char* sig = target_method()->name_and_sig_as_C_string(); const char* loader1 = SystemDictionary::loader_name(target_loader()); char* current = _klass->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(super_loader()); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + strlen(current) + strlen(loader2) + strlen(failed_type_name); char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, failed_type_name); THROW_MSG_(vmSymbols::java_lang_LinkageError(), buf, false); } } } put_method_at(target_method(), i); target_method()->set_vtable_index(i); #ifndef PRODUCT if (PrintVtables && Verbose) { tty->print("overriding with %s::%s index %d, original flags: ", _klass->internal_name(), (target_method() != NULL) ? target_method()->name()->as_C_string() : "<NULL>", i); super_method->access_flags().print_on(tty); tty->print("overriders flags: "); target_method->access_flags().print_on(tty); tty->cr(); } #endif /*PRODUCT*/ } else {
void RC_visualFollow::onMouseDrawRect(MOUSE* pMouse, BUTTON* pBtn) { NULL_(pMouse); Rect2d roi; int ROIhalf; switch (pMouse->m_event) { case EVENT_LBUTTONDOWN: if (!pBtn) { m_pROITracker->tracking(false); m_ROI.m_x = pMouse->m_x; m_ROI.m_y = pMouse->m_y; m_ROI.m_z = pMouse->m_x; m_ROI.m_w = pMouse->m_y; m_bSelect = true; return; } if (pBtn->m_name == "MODE") { m_ROI.m_x = 0; m_ROI.m_y = 0; m_ROI.m_z = 0; m_ROI.m_w = 0; m_pROITracker->tracking(false); m_bSelect = false; m_ROImode = MODE_ASSIST; return; } break; case EVENT_MOUSEMOVE: CHECK_(!m_bSelect); m_ROI.m_z = pMouse->m_x; m_ROI.m_w = pMouse->m_y; break; case EVENT_LBUTTONUP: roi = getMouseROI(m_ROI); if (roi.width < m_ROIsizeFrom || roi.height < m_ROIsizeFrom) { m_ROI.m_x = 0; m_ROI.m_y = 0; m_ROI.m_z = 0; m_ROI.m_w = 0; } else { m_pROITracker->setROI(roi); m_pROITracker->tracking(true); } m_bSelect = false; break; case EVENT_RBUTTONDOWN: break; default: break; } }
// Update child's copy of super vtable for overrides // OR return true if a new vtable entry is required // Only called for instanceKlass's, i.e. not for arrays // If that changed, could not use _klass as handle for klass bool klassVtable::update_super_vtable(instanceKlass* klass, methodHandle target_method, int super_vtable_len, bool checkconstraints, TRAPS) { ResourceMark rm; bool allocate_new = true; assert(klass->oop_is_instance(), "must be instanceKlass"); // Initialize the method's vtable index to "nonvirtual". // If we allocate a vtable entry, we will update it to a non-negative number. target_method()->set_vtable_index(methodOopDesc::nonvirtual_vtable_index); // Static and <init> methods are never in if (target_method()->is_static() || target_method()->name() == vmSymbols::object_initializer_name()) { return false; } if (klass->is_final() || target_method()->is_final()) { // a final method never needs a new entry; final methods can be statically // resolved and they have to be present in the vtable only if they override // a super's method, in which case they re-use its entry allocate_new = false; } // we need a new entry if there is no superclass if (klass->super() == NULL) { return allocate_new; } // private methods always have a new entry in the vtable if (target_method()->is_private()) { return allocate_new; } // search through the vtable and update overridden entries // Since check_signature_loaders acquires SystemDictionary_lock // which can block for gc, once we are in this loop, use handles, not // unhandled oops unless they are reinitialized for each loop // handles for name, signature, klass, target_method // not for match_method, holder symbolHandle name(THREAD,target_method()->name()); symbolHandle signature(THREAD,target_method()->signature()); for(int i = 0; i < super_vtable_len; i++) { methodOop match_method = method_at(i); // Check if method name matches if (match_method->name() == name() && match_method->signature() == signature()) { instanceKlass* holder = (THREAD, instanceKlass::cast(match_method->method_holder())); // Check if the match_method is accessable from current class bool same_package_init = false; bool same_package_flag = false; bool simple_match = match_method->is_public() || match_method->is_protected(); if (!simple_match) { same_package_init = true; same_package_flag = holder->is_same_class_package(_klass->class_loader(), _klass->name()); simple_match = match_method->is_package_private() && same_package_flag; } // match_method is the superclass' method. Note we can't override // and shouldn't access superclass' ACC_PRIVATE methods // (although they have been copied into our vtable) // A simple form of this statement is: // if ( (match_method->is_public() || match_method->is_protected()) || // (match_method->is_package_private() && holder->is_same_class_package(klass->class_loader(), klass->name()))) { // // The complexity is introduced it avoid recomputing 'is_same_class_package' which is expensive. if (simple_match) { // Check if target_method and match_method has same level of accessibility. The accesibility of the // match method is the "most-general" visibility of all entries at it's particular vtable index for // all superclasses. This check must be done before we override the current entry in the vtable. AccessType at = vtable_accessibility_at(i); bool same_access = false; if ( (at == acc_publicprotected && (target_method()->is_public() || target_method()->is_protected())) || (at == acc_package_private && (target_method()->is_package_private() && (( same_package_init && same_package_flag) || (!same_package_init&&holder->is_same_class_package(_klass->class_loader(),_klass->name())))))){ same_access = true; } if (checkconstraints) { // Override vtable entry if passes loader constraint check // if loader constraint checking requested // No need to visit his super, since he and his super // have already made any needed loader constraints. // Since loader constraints are transitive, it is enough // to link to the first super, and we get all the others. symbolHandle signature(THREAD, target_method()->signature()); Handle this_loader(THREAD, _klass->class_loader()); instanceKlassHandle super_klass(THREAD, _klass->super()); Handle super_loader(THREAD, super_klass->class_loader()); if (this_loader() != super_loader()) { ResourceMark rm(THREAD); char* failed_type_name = SystemDictionary::check_signature_loaders(signature, this_loader, super_loader, true, CHECK_(false)); if (failed_type_name != NULL) { const char* msg = "loader constraint violation: when resolving " "overridden method \"%s\" the class loader (instance" " of %s) of the current class, %s, and its superclass loader " "(instance of %s), have different Class objects for the type " "%s used in the signature"; char* sig = target_method()->name_and_sig_as_C_string(); const char* loader1 = SystemDictionary::loader_name(this_loader()); char* current = _klass->name()->as_C_string(); const char* loader2 = SystemDictionary::loader_name(super_loader()); size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) + strlen(current) + strlen(loader2) + strlen(failed_type_name); char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen); jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2, failed_type_name); THROW_MSG_(vmSymbols::java_lang_LinkageError(), buf, false); } } } put_method_at(target_method(), i); if (same_access) { // target and match has same accessiblity - share entry allocate_new = false; target_method()->set_vtable_index(i); #ifndef PRODUCT if (PrintVtables && Verbose) { AccessType targetacc; if (target_method()->is_protected() || target_method()->is_public()) { targetacc = acc_publicprotected; } else { targetacc = target_method()->is_package_private() ? acc_package_private : acc_private; } tty->print_cr("overriding with %s::%s index %d, original flags: %x overriders flags: %x", _klass->internal_name(), (target_method() != NULL) ? target_method()->name()->as_C_string() : "<NULL>", i, at, targetacc); } #endif /*PRODUCT*/ } else { #ifndef PRODUCT if (PrintVtables && Verbose) { AccessType targetacc; if (target_method()->is_protected() || target_method()->is_public()) { targetacc = acc_publicprotected; } else { targetacc = target_method()->is_package_private() ? acc_package_private : acc_private; } tty->print_cr("override %s %s::%s at index %d, original flags: %x overriders flags: %x", allocate_new ? "+ new" : "only", _klass->internal_name(), (target_method() != NULL) ? target_method()->name()->as_C_string() : "<NULL>", i, at, targetacc); } #endif /*PRODUCT*/ } } }
/** * Gets the singleton HotSpotJVMCIRuntime instance, initializing it if necessary */ static Handle get_HotSpotJVMCIRuntime(TRAPS) { initialize_JVMCI(CHECK_(Handle())); return Handle(JNIHandles::resolve_non_null(_HotSpotJVMCIRuntime_instance)); }