반응형

아버지의 정부인 Johanna에게 사랑을 느끼게 된 Thomas는 같은 건물에 사는 이웃 W.F와 이야기를 나누며 인생에 대한 조언을 구합니다. Thomas는 나중에 죄책감이 들지 모르겠지만 지금은 아니라 얘기하지요.


W.F: I'm gonna take this. Leave you with your heart on.

Thomas: With my hard-on?

W.F: Heart. Your heart on.


The only living boy in New York



Thomas: You know what, maybe, in hindsight, I'll feel guilty about Johanna, but right now I don't. It's not cut or dry.


'cut and dried'라는 표현은 '허브를 자르고 말리는 과정'에서 나온 것으로 생각되는데, '이미 확정된', '변경 불가능한'이라는 의미입니다. 여기서 조금 더 의미가 확장되어 '무미건조한', '상투적인', '평범한'을 의미 하기도 합니다. 간혹 'cut and dry'로 쓰기도 하지만 'cut and dried'로 쓰는 경우가 훨씬 더 많습니다.


'carved in stone - (결정, 계획 등이) 변경 불가능한' 이라는 표현도 함께 알아두면 좋을거 같네요.


반응형
Posted by J-sean
:
반응형

Thomas의 엄마 Judith는 Andy Warhol이 선물로 준 사진을 찾다 잠시 담배를 피기 위해 집 밖으로 나가고 싶어 합니다.


Thomas: All right, well, I'll stay here and keep searching.

Judith: Thomas, I want to smoke and talk to you at the same time. It makes the cigarette better.

Thomas: Okay.

Judith: Thank you.


The only living boy in New York



Judith: It's just this perpetual cycle of expectations and disappointments. You know? The farthest distance in the world is between how it is and how you thought it was gonna be. Don't forget that.

Thomas: I won't.

Judith: You're my light, Thomas. You know? I don't know what I'd do without you.


기대가 크면 실망도 크다는걸 기대와 실망의 영원한 반복, 이상과 현실의 먼 거리로 설명하고 있습니다.


반응형
Posted by J-sean
:
반응형

Thomas와 Mimi는 전시회장에서 '1976년 3월 29일 The New Yorker'라는 포스터를 보며 New York에 대한 이야기를 나눕니다.


Thomas: New York's lost its soul. The most vibrant neighborhood at the moment is Philadelphia.

Mimi: I like that.

Thomas: Yeah?


The only living boy in New York



Mimi: Yeah. Where'd you lift that from?

Thomas: I didn't. It's mine.

Mimi: Well, it's good.


lift는 shoplift에서 알 수 있듯이 '~을 훔치다'라는 뜻을 가지고 있습니다. 이 의미는 발전하여 문장 또는 아이디어등을 '훔치다', '도용하다', '표절하다(plagiarize)'라는 의미도 가지게 되었지요.


이 장면의 Mimi의 대사 'Where'd you lift that from?' 은 '어디서 도용한 말이야?'라기 보다는 '어디서 들은 말이야?'로 보는게 자연스러울거 같네요.


반응형
Posted by J-sean
:
반응형

Thomas Webb은 친구인 Mimi를 좋아합니다. Thomas의 이런 마음을 모르는지 어느날 전시회장에서 Mimi는 Thomas에게 Croatia에 가려는 계획을 이야기 합니다. 하지만 Mimi가 Croatia에 가지 않기를 바라는 Thomas는 Mimi를 설득합니다.


Thomas: Well, I'm crazy about you.

Mimi: I'm crazy about you, but...

Thomas: But don't say 'as friends'.

Mimi: Why? Why is that so bad?


The only living boy in New York



Thomas: Because pretty girls like to recruit their rejections and then call them friends.

Mimi: Wow...


물고기가 대량으로 잡히는 어장은 영어로 fishery라고 합니다. 우리 말을 그대로 직역하면 fishery라는 단어를 사용 하겠지만 문화가 다른 미국에서는 '회원', '신병'등을 '모집하다'라는 뜻을 가진 recruit와 '거절'이라는 명사 rejection을 이용해 같은 의미를 전달하는걸 볼 수 있습니다.


reject의 명사는 '불량품', '거부당한 사람'등을 의미한다는 점도 참고 하세요.


반응형
Posted by J-sean
:
반응형

Function execution time can be measured by counting ticks after a certain event (for example, when the machine was turned on).

Below code shows how to do this.


getTickCount()나 TickMeter 클래스를 이용해 실행 시간을 계산 할 수 있다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <opencv2/opencv.hpp>
 
using namespace std;
using namespace cv;
 
int main(int argc, char** argv)
{
    RNG rng(getTickCount());
    Mat mat(300400, CV_8SC3);
    
    double start =  (double)getTickCount(); // Returns the number of ticks.
    rng.fill(mat, RNG::UNIFORM, Scalar::all(0), Scalar::all(255));
    // getTickFrequency() - Returns the number of ticks per second.
    double duration = ((double)getTickCount() - start) / getTickFrequency();
    cout << "Duration measured by getTickCount(): " << duration << endl;
    imshow("getTickCount", mat);
 
    // TickMeter class computes passing time by counting the number of ticks per second.
    TickMeter tm;
    tm.start(); // Starts counting ticks.
    rng.fill(mat, RNG::UNIFORM, Scalar::all(0), Scalar::all(255));
    tm.stop(); // Stops counting ticks.
    // Returns passed time in seconds.
    cout << "Duration measured by TickMeter: " << tm.getTimeSec() << endl;
    imshow("TickMeter", mat);
 
    waitKey(0);
 
    return 0;
}
cs








반응형
Posted by J-sean
:
반응형

Random number generator. It encapsulates the state (currently, a 64-bit integer) and has methods to return scalar random values and to fill arrays with random values. Currently, it supports uniform and Gaussian (normal) distributions. The generator uses Multiply-With-Carry algorithm, introduced by G. Marsaglia (http://en.wikipedia.org/wiki/Multiply-with-carry). Gaussian-distribution random numbers are generated using the Ziggurat algorithm (http://en.wikipedia.org/wiki/Ziggurat_algorithm), introduced by G. Marsaglia and W. W. Tsang.


아래 코드는 OpenCV에서 지원하는 난수 발생기의 사용 방법 입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <opencv2/opencv.hpp>
 
using namespace std;
using namespace cv;
 
int main(int argc, char** argv)
{
    RNG rng(getTickCount());    // Constructor sets the state to the specified value.
    Mat mat(300400, CV_8SC3);
    
    // Fills arrays with random numbers.
    rng.fill(mat, RNG::UNIFORM, Scalar::all(0), Scalar::all(255));
    
    // Returns uniformly distributed integer random number from [a,b) range
    cout << "RNG::uniform()" << endl;
    cout << "- rng.uniform(0, 255): " << rng.uniform(0255<< endl;
    cout << "- rng.uniform(0.0f, 255.0f): " << rng.uniform(0.0f, 255.0f) << endl;
    cout << "- rng.uniform(0.0, 255.0): " << rng.uniform(0.0255.0<< endl << endl;
 
    // Returns a random integer sampled uniformly from [0, N).
    cout << "RNG::operator()" << endl;
    for (int i = 0; i < 5; i++)
        cout << "- rng(10): " << rng(10<< endl;
 
    // The method updates the state using the MWC algorithm and returns
    // the next 32-bit random number.
    cout << endl << "RNG::next()" << endl;
    for (int i = 0; i < 5; i++)
        cout << "- rng.next(): " << rng.next() << endl;
 
    imshow("RNG", mat);
 
    waitKey(0);
 
    return 0;
}
cs



Matrix filled by RNG::fill().


Random numbers generated by RNG.



반응형
Posted by J-sean
:
반응형

Below code shows how to use cv::String class.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <opencv2/opencv.hpp>
 
using namespace std;
using namespace cv;
 
int main(int argc, char** argv)
{
    const char* str = "Open Source Computer Vision";
    String str1("Hello World");
    String str2(str, str+11);
    String str3 = "Software Engineer";
 
    cout << "str1: " << str1 << endl << "str2: " << str2 << endl
        << "str3: " << str3 << endl << endl;
 
    cout << "*str1.begin(): " << *str1.begin() << endl;
    cout << "str1[1]: " << str1[1<< endl;
    cout << "*(str1.end()-1): " << *(str1.end()-1<< endl << endl;
 
    cout << "str2.size(): " << str2.size() << endl;
    cout << "str2.length(): " << str2.length() << endl;
    cout << "str2.empty(): " << str2.empty() << endl;
    cout << "str3.find(\"ng\"): " << str3.find("ng"<< endl << endl;
 
    cout << "format(\"%s %d\", str3.c_str(), 100): " << format("%s %d", str3.c_str(), 100<< endl;
    cout << "str3.toLowerCase(): " << str3.toLowerCase() << endl;
    cout << "str3.substr(2, 4): " << str3.substr(24<< endl << endl;
 
    str1.swap(str3);
    cout << "str1.swap(str3)" << endl;
    cout << "- str1: " << str1 << endl << "- str3: " << str3 << endl;
    str1.clear();
    cout << "str1.clear()" << endl;
    cout << "- str1: " << endl;
 
    return 0;
}
cs






반응형
Posted by J-sean
:
반응형

Only two matching methods currently accept a mask: CV_TM_SQDIFF and CV_TM_CCORR_NORMED


The mask should have a CV_8U or CV_32F depth and the same number of channels and size as the target image. In CV_8U case, the mask values are treated as binary, i.e. zero and non-zero. In CV_32F case, the values should fall into [0..1] range and the target image pixels will be multiplied by the corresponding mask pixel values.


OpenCV matchTemplate 함수에 마스크를 적용해서 (배경이 다른) 같은 이미지를 모두 찾을 수 있다. 마스크는 CV_8U 아니면 CV_32F의 깊이값을 가져야 하며 target image와 같은 채널 수와 사이즈를 가져야 한다.


2019/07/08 - [Software/OpenCV] - Template Matching(Image Searching) - 부분 이미지 검색

2019/07/10 - [Software/OpenCV] - Template Matching(Image Searching) for multiple objects - 반복되는 이미지 모두 찾기


<Target>


<Mask>


<Source>


There are 3 objects(bones) to find in the source image.

Each of them has a different background as below.


Below code explains how to spot different background multiple objects with a mask.

Adjust threshold value if it doesn't work properly.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <opencv2/opencv.hpp>
#include <time.h>
 
using namespace cv;
using namespace std;
 
int main()
{
    clock_t start, end;
    double minVal;
    Point minLoc;
    double threshold = 0.001;
    int count = 0;
 
    Mat FinalImage = imread("source.png", IMREAD_COLOR);
    if (FinalImage.empty())
        return -1;
 
    // Grayscale source, target and mask for faster calculation.
    Mat SourceImage;
    cvtColor(FinalImage, SourceImage, CV_BGR2GRAY);
 
    Mat TargetImage = imread("target.png", IMREAD_GRAYSCALE);
    if (TargetImage.empty())
        return -1;
 
    Mat Mask = imread("mask.png", IMREAD_GRAYSCALE);
    if (Mask.empty())
        return -1;
 
    Mat Result;
 
    start = clock();
    // Mask must have the same datatype and size with target image.
    // It is not set by default. Currently, only the TM_SQDIFF and TM_CCORR_NORMED methods are supported.
    matchTemplate(SourceImage, TargetImage, Result, TM_SQDIFF, Mask); // Type of the template matching operation: TM_SQDIFF
    normalize(Result, Result, 01, NORM_MINMAX, -1, Mat());
    minMaxLoc(Result, &minVal, NULL&minLoc, NULL);
 
    for (int i = 0; i < Result.rows; i++)
        for (int j = 0; j < Result.cols; j++)
            if (Result.at<float>(i, j) < threshold)
            {
                rectangle(FinalImage, Point(j, i), Point(j + TargetImage.cols, i + TargetImage.rows), Scalar(00255), 1);
                count++;
            }
    end = clock();
 
    cout << "Searching time: " << difftime(end, start) / CLOCKS_PER_SEC << endl;
    cout << "Minimum Value: " << minVal << " " << minLoc << endl;
    cout << "Threshold: " << threshold << endl;
    cout << "Found: " << count << endl;
 
    imshow("Mask", Mask);
    imshow("TargetImage", TargetImage);
    imshow("Result", Result);
    imshow("FinalImage", FinalImage);
 
    waitKey(0);
 
    return 0;
}
cs




Grayscale target image


Binary mask


Result image


Final image


Found 3 bones in 0.097 secs.



반응형
Posted by J-sean
: