Exemple #1
0
//-----------------------------------------------------------------------------
// 説明: ルート位置の設定
// 引数: 
//       frm [in] フレーム番号
//       v [in] 位置ベクトル
// 返り値:
//       true 設定成功
//       false 設定失敗
// その他: 
//-----------------------------------------------------------------------------
bool CMotionData::SetPosition(size_t frm, const Vector3f &v)
{
	if (!IsRange(frm))
		return false;
	POS(frm) = v;
	return true;
}
Exemple #2
0
void VaryVarUnits::AddToListing(UnitListObj& listObj) const
{

    if (IsRange())
    {
        listObj.AddUnitReal("   Minimum", UnitReal(unitIndex, rangeMinLim));
        listObj.AddUnitReal("   Maximum", UnitReal(unitIndex, rangeMaxLim));
        listObj.AddStdInt("   # of steps", rangeNStep);
        listObj.AddBoolText("   Stepping type", rangeIsLinear, "Linear", "Log");
    }
    else
    {
        if (suiteValues.IsEmpty())
        {
            listObj.AddStdText("   # of values", "nonse set");
        }
        for (int i = 0; i < suiteValues.Size(); i++)
        {
            char tempStr[80];
            CopyString(tempStr,"Value #", 80);
            ConcatInt(i, tempStr, 2, 80);
            listObj.AddUnitReal(tempStr, UnitReal(unitIndex, suiteValues[i]));
        }
    }
}
Exemple #3
0
//-----------------------------------------------------------------------------
// 説明: 関節回転量の設定(クォータニオン)
// 引数: 
//       frm [in] フレーム番号
//       jid [in] 関節インデクス
//       q [in] 回転クォータニオン
// 返り値:
//       true 設定成功
//       false 設定失敗
// その他: 
//-----------------------------------------------------------------------------
bool CMotionData::SetRotation(size_t frm, size_t jid, const Quaternionf &q)
{
	if (!IsRange(frm, jid))
		return false;
	ROT(frm, jid) = q;
	return true;
}
Exemple #4
0
//-----------------------------------------------------------------------------
// 説明: ルート位置行列の取得
// 引数: 
//       frm [in] フレーム番号
// 返り値:
//       ルート位置行列
// その他: 
//-----------------------------------------------------------------------------
Matrix4f CMotionData::GetPositionMatrix(size_t frm) const
{
	Matrix4f m = Matrix4f::Identity();
	if (!IsRange(frm))
		return m;
	Vector3f v = POS(frm);
	NEigenMath::Matrix4fTranslation(&m, v.x(), v.y(), v.z());
	//Matrix4fTranslation(&m, v.x, v.y, v.z);
	return m;
}
Exemple #5
0
//-----------------------------------------------------------------------------
// 説明: 関節回転行列の取得
// 引数: 
//       frm [in] フレーム番号
//       jid [in] 関節インデクス
// 返り値:
//       関節回転行列
// その他: 
//-----------------------------------------------------------------------------
Matrix4f CMotionData::GetRotationMatrix(size_t frm, size_t jid) const
{
	Matrix4f m = Matrix4f::Identity();
	if (!IsRange(frm, jid))
		return m;
	NEigenMath::Matrix4fRotationQuaternion(&m, &ROT(frm, jid));
	//m.block(0,0,3,3) = Matrix3f( ROT(frm, jid) );
	//Matrix4fRotationQuaternion(&m, &ROT(frm, jid));
	return m;
}
Exemple #6
0
//-----------------------------------------------------------------------------
// 説明: 関節回転量の設定(回転行列)
// 引数: 
//       frm [in] フレーム番号
//       jid [in] 関節インデクス
//       m [in] 回転行列
// 返り値:
//       true 設定成功
//       false 設定失敗
// その他: 
//-----------------------------------------------------------------------------
bool CMotionData::SetRotation(size_t frm, size_t jid, const Matrix4f &m)
{
	if (!IsRange(frm, jid))
		return false;
	NEigenMath::QuaternionfRotationMatrix(&ROT(frm,jid), &m);
	//AngleAxisf tmp;tmp = Matrix3f(m.block(0,0,3,3));
	//ROT(frm, jid) = Quaternionf(tmp);
	//QuaternionfRotationMatrix(&ROT(frm, jid), &m);
	return true;
}
CString EffectValueOrRange::ToString() const
{
   CString cszText;

   cszText.Format(IsRange() ? _T("%i%s-%i%s") : _T("%i%s"),
      m_iValues[0], m_bPercent ? _T("%") : _T(""),
      m_iValues[1], m_bPercent ? _T("%") : _T(""));

   return cszText;
}
Exemple #8
0
/**
 플레이어 부대를 생성
*/
XSquadron::XSquadron( XSPHero pHero )
{
	Init();
	m_bCreateHero = FALSE;
	XBREAK( pHero == NULL );
	m_pHero = pHero;
	//m_snHero = pHero->GetsnHero();
	auto pPropUnit = PROP_UNIT->GetpProp( pHero->GetUnit() );
	XBREAK( pPropUnit == NULL );
	XBREAK( m_pHero->IsRange() && pPropUnit->IsRange() == FALSE );
}
static void colorExtraction(const cv::Mat& src, // input HSV image
                            cv::Mat*       dst, // specified color extracted binarized image
                            const double   hue_lower, const double hue_upper, // hue thresholds
                            const double   sat_lower, const double sat_upper, // satulation thresholds
                            const double   val_lower, const double val_upper) // value thresholds
{
  /* create imput image copy */
  cv::Mat input_img = src.clone();

  *dst = cv::Scalar::all(0);

  /*
    ref:
    http://qiita.com/crakaC/items/65fab9d0b0ac29e68ab6
   */

  /* create LookUp Table */
  cv::Mat lut(256, 1, CV_8UC3);
  for (int i=0; i<256; i++)
    {
	  lut.at<cv::Vec3b>(i)[0] = (IsRange(hue_lower, hue_upper, Actual_Hue(i))) ? 255 : 0;
	  lut.at<cv::Vec3b>(i)[1] = (IsRange(sat_lower, sat_upper, Actual_Sat(i))) ? 255 : 0;
	  lut.at<cv::Vec3b>(i)[2] = (IsRange(val_lower, val_upper, Actual_Val(i))) ? 255 : 0;
    }

  /* apply LUT to input image */
  cv::Mat extracted(input_img.rows, input_img.cols, CV_8UC3);
  LUT(input_img, lut, extracted);

  /* divide image into each channel */
  std::vector<cv::Mat> channels;
  split(extracted, channels);

  /* create mask */
  bitwise_and(channels[0], channels[1], *dst);
  bitwise_and(*dst, channels[2], *dst);


} /* static void colorExtraction() */
Exemple #10
0
// XSquadron::XSquadron( XSPAccConst spAcc, 
// 											XPropHero::xPROP *pPropHero, 
// 											int levelHero, 
// 											XGAME::xtUnit unit, 
// 											int levelSquad, 
// 											bool bCreateHero )
XSquadron::XSquadron( XPropHero::xPROP *pPropHero,
											int levelHero,
											XGAME::xtUnit unit,
											int levelSquad )
{
	Init();
	XBREAK( pPropHero == nullptr );
//	const auto& prop = PROP_SQUAD->GetTable( levelSquad );
//	m_bCreateHero = (bCreateHero)? TRUE : FALSE;
	m_bCreateHero = true;
	m_pHero = XHero::sCreateHero( pPropHero, levelSquad, unit, nullptr );
	XBREAK( m_pHero == nullptr );
	XBREAK( levelHero <= 0 );
	m_pHero->SetLevel(levelHero);
	m_pHero->SetlevelSquad( levelSquad );

	auto pPropUnit = PROP_UNIT->GetpProp( unit );
	XBREAK( pPropUnit == NULL );
	XBREAK( m_pHero->IsRange() && pPropUnit->IsRange() == FALSE );
}
Exemple #11
0
UniValue getdescriptorinfo(const JSONRPCRequest& request)
{
    if (request.fHelp || request.params.size() != 1) {
        throw std::runtime_error(
            RPCHelpMan{"getdescriptorinfo",
            {"\nAnalyses a descriptor.\n"},
            {
                {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."},
            },
            RPCResult{
            "{\n"
            "  \"descriptor\" : \"desc\",         (string) The descriptor in canonical form, without private keys\n"
            "  \"isrange\" : true|false,        (boolean) Whether the descriptor is ranged\n"
            "  \"issolvable\" : true|false,     (boolean) Whether the descriptor is solvable\n"
            "  \"hasprivatekeys\" : true|false, (boolean) Whether the input descriptor contained at least one private key\n"
            "}\n"
            },
            RPCExamples{
                "Analyse a descriptor\n" +
                HelpExampleCli("getdescriptorinfo", "\"wpkh([d34db33f/84h/0h/0h]0279be667ef9dcbbac55a06295Ce870b07029Bfcdb2dce28d959f2815b16f81798)\"")
            }}.ToString()
        );
    }

    RPCTypeCheck(request.params, {UniValue::VSTR});

    FlatSigningProvider provider;
    auto desc = Parse(request.params[0].get_str(), provider);
    if (!desc) {
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor"));
    }

    UniValue result(UniValue::VOBJ);
    result.pushKV("descriptor", desc->ToString());
    result.pushKV("isrange", desc->IsRange());
    result.pushKV("issolvable", desc->IsSolvable());
    result.pushKV("hasprivatekeys", provider.keys.size() > 0);
    return result;
}
Exemple #12
0
//-----------------------------------------------------------------------------
// 説明: ルート位置ベクトルの取得
// 引数: 
//       frm [in] フレーム番号
// 返り値:
//       ルート位置ベクトル
// その他: 
//-----------------------------------------------------------------------------
Vector3f CMotionData::GetPosition(size_t frm) const
{
	if (!IsRange(frm))
		return Vector3f() = Vector3f::Identity();
	return POS(frm);
}
Exemple #13
0
//-----------------------------------------------------------------------------
// 説明: 関節回転クォータニオンの取得
// 引数: 
//       frm [in] フレーム番号
//       jid [in] 関節インデクス
// 返り値:
//       関節回転クォータニオン
// その他: 
//-----------------------------------------------------------------------------
Quaternionf CMotionData::GetRotation(size_t frm, size_t jid) const
{
	if (!IsRange(frm, jid))
		return Quaternionf() = Quaternionf(0.f, 0.0f, 0.f, 1.0f);
	return ROT(frm, jid);
}
Exemple #14
0
 /**
  * @brief Checks if current character is alphanumeric (a-z|0-9).
  *
  * @return
  */
 bool IsAlphaNumberic() const {
     return IsAlpha() || IsRange('0', '9');
 }
Exemple #15
0
 /**
  * @brief Checks if current character is alpha (a-z).
  *
  * @return
  */
 bool IsAlpha() const {
     return IsRange('a', 'z') || IsRange('A', 'Z');
 }
Exemple #16
0
UniValue deriveaddresses(const JSONRPCRequest& request)
{
    if (request.fHelp || request.params.empty() || request.params.size() > 2) {
        throw std::runtime_error(
            RPCHelpMan{"deriveaddresses",
            {"\nDerives one or more addresses corresponding to an output descriptor.\n"
            "Examples of output descriptors are:\n"
            "    pkh(<pubkey>)                        P2PKH outputs for the given pubkey\n"
            "    wpkh(<pubkey>)                       Native segwit P2PKH outputs for the given pubkey\n"
            "    sh(multi(<n>,<pubkey>,<pubkey>,...)) P2SH-multisig outputs for the given threshold and pubkeys\n"
            "    raw(<hex script>)                    Outputs whose scriptPubKey equals the specified hex scripts\n"
            "\nIn the above, <pubkey> either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one\n"
            "or more path elements separated by \"/\", where \"h\" represents a hardened child key.\n"
            "For more information on output descriptors, see the documentation in the doc/descriptors.md file.\n"},
            {
                {"descriptor", RPCArg::Type::STR, RPCArg::Optional::NO, "The descriptor."},
                {"range", RPCArg::Type::RANGE, RPCArg::Optional::OMITTED_NAMED_ARG, "If a ranged descriptor is used, this specifies the end or the range (in [begin,end] notation) to derive."},
            },
            RPCResult{
                "[ address ] (array) the derived addresses\n"
            },
            RPCExamples{
                "First three native segwit receive addresses\n" +
                HelpExampleCli("deriveaddresses", "\"wpkh([d34db33f/84h/0h/0h]xpub6DJ2dNUysrn5Vt36jH2KLBT2i1auw1tTSSomg8PhqNiUtx8QX2SvC9nrHu81fT41fvDUnhMjEzQgXnQjKEu3oaqMSzhSrHMxyyoEAmUHQbY/0/*)#trd0mf0l\" \"[0,2]\"")
            }}.ToString()
        );
    }

    RPCTypeCheck(request.params, {UniValue::VSTR, UniValueType()}); // Range argument is checked later
    const std::string desc_str = request.params[0].get_str();

    int64_t range_begin = 0;
    int64_t range_end = 0;

    if (request.params.size() >= 2 && !request.params[1].isNull()) {
        std::tie(range_begin, range_end) = ParseDescriptorRange(request.params[1]);
    }

    FlatSigningProvider key_provider;
    auto desc = Parse(desc_str, key_provider, /* require_checksum = */ true);
    if (!desc) {
        throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor"));
    }

    if (!desc->IsRange() && request.params.size() > 1) {
        throw JSONRPCError(RPC_INVALID_PARAMETER, "Range should not be specified for an un-ranged descriptor");
    }

    if (desc->IsRange() && request.params.size() == 1) {
        throw JSONRPCError(RPC_INVALID_PARAMETER, "Range must be specified for a ranged descriptor");
    }

    UniValue addresses(UniValue::VARR);

    for (int i = range_begin; i <= range_end; ++i) {
        FlatSigningProvider provider;
        std::vector<CScript> scripts;
        if (!desc->Expand(i, key_provider, scripts, provider)) {
            throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Cannot derive script without private keys"));
        }

        for (const CScript &script : scripts) {
            CTxDestination dest;
            if (!ExtractDestination(script, dest)) {
                throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Descriptor does not have a corresponding address"));
            }

            addresses.push_back(EncodeDestination(dest));
        }
    }

    // This should not be possible, but an assert seems overkill:
    if (addresses.empty()) {
        throw JSONRPCError(RPC_MISC_ERROR, "Unexpected empty result");
    }

    return addresses;
}
 /// returns range end
 int RangeEnd() const throw()
 {
    ATLASSERT(IsRange() == true);
    return m_iValues[1];
 }
void TrafficLightDetector::brightnessDetect(const cv::Mat &input) {

  cv::Mat tmpImage;
  input.copyTo(tmpImage);

  /* contrast correction */
  cv::Mat tmp;
  cvtColor(tmpImage, tmp, CV_BGR2HSV);
  std::vector<cv::Mat> hsv_channel;
  split(tmp, hsv_channel);

  float correction_factor = 10.0;
  uchar lut[256];
  for (int i=0; i<256; i++) {
    lut[i] = 255.0 / (1 + exp(-correction_factor*(i-128)/255));
  }

  LUT(hsv_channel[2], cv::Mat(cv::Size(256, 1), CV_8U, lut), hsv_channel[2]);
  merge(hsv_channel, tmp);
  cvtColor(tmp, tmpImage, CV_HSV2BGR);

  for (int i = 0; i < static_cast<int>(contexts.size()); i++) {
    Context context = contexts.at(i);

    if (context.topLeft.x > context.botRight.x)
      continue;

    /* extract region of interest from input image */
    cv::Mat roi = tmpImage(cv::Rect(context.topLeft, context.botRight));

    /* convert color space (BGR -> HSV) */
    cv::Mat roi_HSV;
    cvtColor(roi, roi_HSV, CV_BGR2HSV);

    /* search the place where traffic signals seem to be */
    cv::Mat    signalMask    = signalDetect_inROI(roi_HSV, input.clone(), context.lampRadius, context.topLeft);

    /* detect which color is dominant */
    cv::Mat extracted_HSV;
    roi.copyTo(extracted_HSV, signalMask);

    // extracted_HSV.copyTo(roi);
    // imshow("tmpImage", tmpImage);
    // waitKey(5);

    cvtColor(extracted_HSV, extracted_HSV, CV_BGR2HSV);

    int red_pixNum    = 0;
    int yellow_pixNum = 0;
    int green_pixNum  = 0;
    int valid_pixNum  = 0;
    for (int y=0; y<extracted_HSV.rows; y++)
      {
        for (int x=0; x<extracted_HSV.cols; x++)
          {
            /* extract H, V value from pixel */
            double hue = Actual_Hue(extracted_HSV.at<cv::Vec3b>(y, x)[0]);
            uchar  val = extracted_HSV.at<cv::Vec3b>(y, x)[2];

            if (val == 0) {
              continue;         // this is masked pixel
            }
            valid_pixNum++;

            /* search which color is actually bright */
            if (IsRange(thSet.Red.Hue.lower, thSet.Red.Hue.upper, hue)) {
              red_pixNum++;
            }

            if (IsRange(thSet.Yellow.Hue.lower, thSet.Yellow.Hue.upper, hue)) {
              yellow_pixNum++;
            }

            if (IsRange(thSet.Green.Hue.lower, thSet.Green.Hue.upper, hue)) {
              green_pixNum++;
            }
          }
    }

    // std::cout << "(green, yellow, red) / valid = (" << green_pixNum << ", " << yellow_pixNum << ", " << red_pixNum << ") / " << valid_pixNum <<std::endl;

    bool isRed_bright;
    bool isYellow_bright;
    bool isGreen_bright;

    if (valid_pixNum > 0) {
      isRed_bright    = ( ((double)red_pixNum / valid_pixNum)    > 0.45) ? true : false; // detect red a little largely
      isYellow_bright = ( ((double)yellow_pixNum / valid_pixNum) > 0.5) ? true : false;
      isGreen_bright  = ( ((double)green_pixNum / valid_pixNum)  > 0.5) ? true : false;
    } else {
      isRed_bright    = false;
      isYellow_bright = false;
      isGreen_bright  = false;
    }

    int currentLightsCode = getCurrentLightsCode(isRed_bright, isYellow_bright, isGreen_bright);
    contexts.at(i).lightState = determineState(contexts.at(i).lightState, currentLightsCode, &(contexts.at(i).stateJudgeCount));

    roi.setTo(cv::Scalar(0));
  }
}