<commit_before>#include "stdafx.h"
#include "CppUnitTest.h"

#include "relative_pose.h"
#include "utils_tests.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace yasfm_tests
{
	TEST_CLASS(relative_pose_tests)
	{
	public:

    TEST_METHOD(chooseInitialCameraPairTest)
    {
      int minMatches = 1;
      vector<NViewMatch> matches(3);
      int numCams = 4;
      ArrayXXi matchesOfPairs(ArrayXXi::Zero(numCams,numCams));

      vector<int> priority(numCams,0);
      priority[0] = 1;
      priority[1] = 1;

      IntPair initPair = chooseInitialCameraPair(minMatches,matches,numCams);
      Assert::IsTrue(initPair.first == -1 && initPair.second == -1);

      initPair = chooseInitialCameraPair(minMatches,matches,priority);
      Assert::IsTrue(initPair.first == -1 && initPair.second == -1);

      initPair = chooseInitialCameraPair(minMatches,matchesOfPairs,priority);
      Assert::IsTrue(initPair.first == -1 && initPair.second == -1);

      matchesOfPairs(0,1) = 1;
      matchesOfPairs(1,2) = 2;
      matches[0].emplace(0,0);
      matches[0].emplace(1,0);
      matches[1].emplace(1,0);
      matches[1].emplace(2,0);
      matches[2].emplace(1,0);
      matches[2].emplace(2,0);

      initPair = chooseInitialCameraPair(minMatches,matches,numCams);
      Assert::IsTrue(initPair.first == 1 && initPair.second == 2);

      initPair = chooseInitialCameraPair(minMatches,matches,priority);
      Assert::IsTrue(initPair.first == 0 && initPair.second == 1);

      initPair = chooseInitialCameraPair(minMatches,matchesOfPairs,priority);
      Assert::IsTrue(initPair.first == 0 && initPair.second == 1);
    }
    
    TEST_METHOD(F2PsTest)
    {
      Matrix34d P = generateRandomProjection();
      Matrix3d ex;
      crossProdMat(P.col(3),&ex);
      Matrix3d F = ex*P.leftCols(3);

      Matrix34d _P;
      F2Ps(F,&_P);

      crossProdMat(_P.col(3),&ex);
      Matrix3d _F = ex*_P.leftCols(3);
<commit_msg>chooseInitialCameraPair unit test change<commit_after>#include "stdafx.h"
#include "CppUnitTest.h"

#include "relative_pose.h"
#include "utils_tests.h"

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace yasfm_tests
{
	TEST_CLASS(relative_pose_tests)
	{
	public:

    TEST_METHOD(chooseInitialCameraPairTest)
    {
      int minMatches = 1;
      double minScore = 1.;
      int numCams = 4;
      ArrayXXi numMatches(ArrayXXi::Zero(numCams,numCams));
      ArrayXXd scores(ArrayXXd::Zero(numCams,numCams));
      uset<int> camsToUse;

      IntPair initPair = chooseInitialCameraPair(minMatches,minScore,camsToUse,numMatches,
        scores);
      Assert::IsTrue(initPair.first == -1 && initPair.second == -1);

      camsToUse.insert(0);
      camsToUse.insert(1);
      initPair = chooseInitialCameraPair(minMatches,minScore,camsToUse,numMatches,
        scores);
      Assert::IsTrue(initPair.first == -1 && initPair.second == -1);

      numMatches(1,0) = numMatches(0,1) = 1;
      numMatches(2,1) = numMatches(1,2) = 2;
      scores(1,0) = scores(0,1) = 1.;
      scores(2,1) = scores(1,2) = 2.;

      initPair = chooseInitialCameraPair(minMatches,minScore,camsToUse,numMatches,
        scores);
      Assert::IsTrue(initPair.first == 0 && initPair.second == 1);

      camsToUse.insert(2);
      initPair = chooseInitialCameraPair(minMatches,minScore,camsToUse,numMatches,
        scores);
      Assert::IsTrue(initPair.first == 1 && initPair.second == 2);

      scores(2,1) = scores(1,2) = .5;
      initPair = chooseInitialCameraPair(minMatches,minScore,camsToUse,numMatches,
        scores);
      Assert::IsTrue(initPair.first == 0 && initPair.second == 1);
    }
    
    TEST_METHOD(F2PsTest)
    {
      Matrix34d P = generateRandomProjection();
      Matrix3d ex;
      crossProdMat(P.col(3),&ex);
      Matrix3d F = ex*P.leftCols(3);

      Matrix34d _P;
      F2Ps(F,&_P);

      crossProdMat(_P.col(3),&ex);
      Matrix3d _F = ex*_P.leftCols(3);

{'fraction_non_alphanumeric': 0.1389452332657201, 'fraction_numerical': 0.02814401622718053, 'mean_word_length': 3.5554272517321017, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2742198', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1393, 'n_words': 201}