Programming/openCV2015. 10. 14. 21:38

tpos + ((matchLoc.x - 160) * 60 / (180/60) /  320);



해놓고는 왜 이게 대충 근사로 되는지 모르겠네 -_-

일단.. 서보 모터는 180도 움직일 수 있고
이 값이 30~110 까지로 설정이 되지만 trackbar에서는 0~100으로 설정되니 일단 패스

카메라 하나의 시야각은 60도로 근사하고
화면상에 보이는 각도는0~100중 0~33으로 가정하여
계산을 한다
그리고 화면 해상도(클릭 범위)는 0~319로 320 범위로 생각

그러면 클릭 위치를 중심점에서 부터 빼서
(matchLoc.x - (320 / 2)) / 320 로 중심점을 계산하고
음의 방향이 될지 양의 방향이 될지 계산한다.


현재 화면의 화각은 60도로

전체 범위(0~100) 에서 1/3 사이즈로 계산한다.

/ (180 / 60)



전체 수식으로는

현재 화면에서의 비율 * 화면 하나의 각도 * 화면 하나의 서보에 대한 비율


 ( 현재 점 - 중심점 )                                     카메라 영상 각도(60')

----------------------- *  카메라 영상 각도(60') * ----------------------------

카메라 영상폭(320px)                                     서보 이동 각도(180')



이 되려나?

하고 나니 나도 헷갈리네.. ㅠㅠ




---------------

일단은 백업..

한쪽 버전


$ cat cv.cpp

#include <opencv2/core/core.hpp>

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <iostream>


#include <wiringPi.h>


#define MIN_POS 30

#define MAX_POS 110


using namespace cv;

using namespace std;


bool bMouse = true;

Point mpos(160,120);


void CallBackFunc(int event, int x, int y, int flags, void* userdata)

{


        switch(event)

        {

        default:

                break;


        case EVENT_LBUTTONDOWN:

                cout << "EVENT_LBUTTONDOWN" << endl;

                cout << "pos (" << x << "," << y << ")" << endl;

                mpos.x = x;

                mpos.y = y;

                bMouse = true;

                break;

        case EVENT_LBUTTONUP:

                cout << "EVENT_LBUTTONUP" << endl;

                break;

        case EVENT_RBUTTONDOWN:

                cout << "EVENT_RBUTTONDOWN" << endl;

                bMouse = true;

                break;

        }

}


void init_wiringpi()

{

        if(wiringPiSetup() == -1) exit(0);


        pinMode(1, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pinMode(23, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pwmWrite(1,     MIN_POS + (MAX_POS - MIN_POS) / 2);

        pwmWrite(23,    MIN_POS + (MAX_POS - MIN_POS) / 2);

}


void setPWM_1(int val)

{

        pwmWrite(23, val);

}


void setPWM_2(int val)

{

        pwmWrite(1, val);

}



void on_trackbar_1(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_1(val);


        cout << "pos 1 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_2(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_2(val);


        cout << "pos 2 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_3(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

//      setPWM_1(val);

//      setPWM_2(val);


        setTrackbarPos("track 1", "cam 1", pos);

        setTrackbarPos("track 2", "cam 2", pos);


        cout << "pos 3 [" << pos << ":" << val << "]" << endl;

}


int main(int argc, char** argv)

{

        // opencv 2 style

        VideoCapture cap(0);

        int pos[2];


        init_wiringpi();


        if(!cap.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }

/*

        VideoCapture cap2(1);

        if(!cap2.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap2.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap2.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }

*/

        namedWindow("cam 1", WINDOW_AUTOSIZE );

//      namedWindow("cam 2", WINDOW_AUTOSIZE );

        namedWindow("control", WINDOW_AUTOSIZE );

        namedWindow("crop", WINDOW_AUTOSIZE );


        createTrackbar("track 1", "cam 1", &pos[0], 100, on_trackbar_1 );

//      createTrackbar("track 2", "cam 2", &pos[1], 100, on_trackbar_2 );

//      createTrackbar("track 3", "control", &pos[0], 100, on_trackbar_3 );


        setTrackbarPos("track 1", "cam 1", 50);

//      setTrackbarPos("track 2", "cam 2", 50);

//      setTrackbarPos("track 3", "control", 50);


        setMouseCallback("cam 1", CallBackFunc, NULL);


        Mat frame;

        Mat result;

        Mat tMat;

        Mat crop;


        double minVal;

        double maxVal;

        Point minLoc;

        Point maxLoc;

        Point matchLoc;


        for(;;)

        {


                Point pt[2];

                if(!cap.read(frame)) break;

                        pt[0].x = 150;

                        pt[0].y = 110;

                        pt[1].x = pt[0].x + 20;

                        pt[1].y = pt[0].y + 20;


                if(bMouse)

                {

                        tMat = frame.clone();

                        crop = Mat(tMat, Rect(mpos.x - 10, mpos.y - 10, 20, 20));

                        imshow("crop", crop);

                }


                matchTemplate( frame, crop, result, CV_TM_SQDIFF );

                normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

                minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

                matchLoc = minLoc;

                cout << "matchLoc : " << matchLoc << endl;


                rectangle(frame, pt[0], pt[1], Scalar(0,0,0),2);

                rectangle(frame, Point(mpos.x - 10, mpos.y - 10), Point(mpos.x + 10, mpos.y + 10), Scalar(0,0,255),2);

                rectangle(frame, matchLoc, Point( matchLoc.x + 20 , matchLoc.y + 20 ), Scalar(0,255,0), 2);

#define SERVO_ANG       180

#define CAM_FOV         60

                if(bMouse)

                {

                        int tpos = getTrackbarPos("track 1", "cam 1");

//                      int value = tpos + (matchLoc.x - 160) * 3 * 2/ 100;

//                      int value = tpos + (100 / (SERVO_ANG / CAM_FOV)) * (matchLoc.x / 320) ;

                        int value = tpos + ((matchLoc.x - 160) * 60 / 3 /  320);

                        cout << "---- calc : " <<  value << endl;

                        setTrackbarPos("track 1", "cam 1", value);

                        bMouse = false;

                }


                imshow("cam 1", frame);

/*

                if(!cap2.read(frame)) break;

                rectangle(frame, pt[0], pt[1], Scalar(0,0,0),2);


                matchTemplate( frame, crop, result, CV_TM_SQDIFF );

                normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

                minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

                matchLoc = minLoc;

                cout << "matchLoc : " << matchLoc << endl;


                rectangle(frame, matchLoc, Point( matchLoc.x + 20 , matchLoc.y + 20 ), Scalar(0,255,0), 2);

                        imshow("cam 2", frame);

*/

                if(waitKey(30) >= 0) break;

        }


        return 0;

} 



두쪽 버전

$ cat cv.cpp

#include <opencv2/core/core.hpp>

#include <opencv2/highgui/highgui.hpp>

#include <opencv2/imgproc/imgproc.hpp>

#include <iostream>


#include <wiringPi.h>


#define MIN_POS 30

#define MAX_POS 110


using namespace cv;

using namespace std;


bool bMouse = true;

Point mpos(160,120);


void CallBackFunc(int event, int x, int y, int flags, void* userdata)

{


        switch(event)

        {

        default:

                break;


        case EVENT_LBUTTONDOWN:

                cout << "EVENT_LBUTTONDOWN" << endl;

                cout << "pos (" << x << "," << y << ")" << endl;

                mpos.x = x;

                mpos.y = y;

                bMouse = true;

                break;

        case EVENT_LBUTTONUP:

                cout << "EVENT_LBUTTONUP" << endl;

                break;

        case EVENT_RBUTTONDOWN:

                cout << "EVENT_RBUTTONDOWN" << endl;

                bMouse = true;

                break;

        }

}


void init_wiringpi()

{

        if(wiringPiSetup() == -1) exit(0);


        pinMode(1, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pinMode(23, PWM_OUTPUT);

        pwmSetMode(PWM_MODE_MS);

        pwmSetRange(1024);

        pwmSetClock(400);


        pwmWrite(1,     MIN_POS + (MAX_POS - MIN_POS) / 2);

        pwmWrite(23,    MIN_POS + (MAX_POS - MIN_POS) / 2);

}


void setPWM_1(int val)

{

        pwmWrite(23, val);

}


void setPWM_2(int val)

{

        pwmWrite(1, val);

}



void on_trackbar_1(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_1(val);


        cout << "pos 1 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_2(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_2(val);


        cout << "pos 2 [" << pos << ":" << val << "]" << endl;

}


void on_trackbar_3(int pos, void *ptr)

{

        int val = MIN_POS + pos * (MAX_POS - MIN_POS) / 100;

        setPWM_1(val);

        setPWM_2(val);


        setTrackbarPos("track 1", "cam 1", pos);

        setTrackbarPos("track 2", "cam 2", pos);


        cout << "pos 3 [" << pos << ":" << val << "]" << endl;

}


int main(int argc, char** argv)

{

        // opencv 2 style

        VideoCapture cap(0);

        int pos[2];


        init_wiringpi();


        if(!cap.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }


        VideoCapture cap2(1);

        if(!cap2.isOpened())

        {

                cout << "No camera detected" << endl;

                return -1;

        }

        else

        {

                cout << "In capture ..." << endl;

                cap2.set(CV_CAP_PROP_FRAME_WIDTH, 320);

                cap2.set(CV_CAP_PROP_FRAME_HEIGHT, 240);

        }


        namedWindow("cam 1", WINDOW_AUTOSIZE );

        namedWindow("cam 2", WINDOW_AUTOSIZE );

        namedWindow("control", WINDOW_AUTOSIZE );

        namedWindow("crop", WINDOW_AUTOSIZE );


        createTrackbar("track 1", "cam 1", &pos[0], 100, on_trackbar_1 );

        createTrackbar("track 2", "cam 2", &pos[1], 100, on_trackbar_2 );

        createTrackbar("track 3", "control", &pos[0], 100, on_trackbar_3 );


        setTrackbarPos("track 1", "cam 1", 50);

        setTrackbarPos("track 2", "cam 2", 50);

        setTrackbarPos("track 3", "control", 50);


        setMouseCallback("cam 1", CallBackFunc, NULL);


        Mat frame;

        Mat result;

        Mat tMat;

        Mat crop;


        double minVal;

        double maxVal;

        Point minLoc;

        Point maxLoc;

        Point matchLoc;


        for(;;)

        {


                Point pt[2];

                if(!cap.read(frame)) break;

                        pt[0].x = 150;

                        pt[0].y = 110;

                        pt[1].x = pt[0].x + 20;

                        pt[1].y = pt[0].y + 20;


                if(bMouse)

                {

                        tMat = frame.clone();

                        crop = Mat(tMat, Rect(mpos.x - 10, mpos.y - 10, 20, 20));

                        imshow("crop", crop);

                }


                matchTemplate( frame, crop, result, CV_TM_SQDIFF );

                normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

                minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

                matchLoc = minLoc;

                cout << "matchLoc : " << matchLoc << endl;


                rectangle(frame, pt[0], pt[1], Scalar(0,0,0),2);

                rectangle(frame, Point(mpos.x - 10, mpos.y - 10), Point(mpos.x + 10, mpos.y + 10), Scalar(0,0,255),2);

                rectangle(frame, matchLoc, Point( matchLoc.x + 20 , matchLoc.y + 20 ), Scalar(0,255,0), 2);

#define SERVO_ANG       180

#define CAM_FOV         60

                if(bMouse)

                {

                        int tpos = getTrackbarPos("track 1", "cam 1");

                        int value = tpos + ((matchLoc.x - 160) * 60 / 3 /  320);

                        cout << "---- calc : " <<  value << endl;

                        setTrackbarPos("track 1", "cam 1", value);

                }


                imshow("cam 1", frame);


                if(!cap2.read(frame)) break;

                rectangle(frame, pt[0], pt[1], Scalar(0,0,0),2);


                matchTemplate( frame, crop, result, CV_TM_SQDIFF );

                normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );

                minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );

                matchLoc = minLoc;

                cout << "matchLoc : " << matchLoc << endl;


                rectangle(frame, matchLoc, Point( matchLoc.x + 20 , matchLoc.y + 20 ), Scalar(0,255,0), 2);

                if(bMouse)

                {

                        int tpos = getTrackbarPos("track 2", "cam 2");

                        int value = tpos + ((matchLoc.x - 160) * 60 / 3 /  320);

                        cout << "---- calc : " <<  value << endl;

                        setTrackbarPos("track 2", "cam 2", value);

                        bMouse = false;

                }

                imshow("cam 2", frame);


                if(waitKey(30) >= 0) break;

        }


        return 0;

} 


'Programming > openCV' 카테고리의 다른 글

opencv 카메라 왜곡 수정  (0) 2015.10.20
opencv sift surf  (0) 2015.10.20
openCV + openMP 합치는게 잘 안되네?  (0) 2015.10.11
opencv 마우스 이벤트와 빠르게 그리기  (0) 2015.10.05
opencv 마우스 이벤트 관련 2  (0) 2015.10.05
Posted by 구차니
파일방2015. 10. 14. 16:22

지인이 쓰는데 좋아 보이길래..


[링크 : http://www.desktopcal.com/]

'파일방' 카테고리의 다른 글

playonlinux - 플레이온 리눅스  (0) 2016.02.02
hfs - HTTP file server  (0) 2015.11.23
라즈베리 파이 오디오 스트리밍 관련 문서  (0) 2015.09.18
HelpNDoc  (0) 2015.07.29
goahead 웹 서버  (0) 2015.07.19
Posted by 구차니
하드웨어/모터(motor)2015. 10. 14. 16:01

[링크 : http://www-stud.uni-due.de/~sbadpras/...-in-daisy-chain-mode/소스코드

[링크 : https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/slave-select-ss] SPI daisy chain

[링크 : http://www.st.com/.../application_note/DM00039787.pdf]


하나랑 통신할때는 비트 단위로 보낸다면...

Daisy chain 시에는 바이트 단위로 묶인 순서의 반대대로(먼 순서 부터) 보낸다.

[링크 : http://www.st.com/.../datasheet/CD00255075.pdf]


ti stellarisware에서 32bit 단위로 하면 최대 4대 까지 가능하려나?

어떻게 될지 모르겠네...


---

비교는 해봐야겠다.. 데이지 체인용으로 수정한 코드라는데..

[링크 : http://www.deathbylogic.com/2015/01/daisy-chaining-multiple-autodrivers/]

[링크 : https://github.com/DeathByLogic/L6470-AutoDriver/tree/daisy_chain]

Posted by 구차니
embeded/raspberry pi2015. 10. 14. 13:14

온도/습도 센서 인데..

검색하다 보니 차이가 있... 다?


DHT11

Ultra low cost

3 to 5V power and I/O

2.5mA max current use during conversion (while requesting data)

Good for 20-80% humidity readings with 5% accuracy

Good for 0-50°C temperature readings ±2°C accuracy

No more than 1 Hz sampling rate (once every second)

Body size 15.5mm x 12mm x 5.5mm

4 pins with 0.1" spacing


DHT22

Low cost

3 to 5V power and I/O

2.5mA max current use during conversion (while requesting data)

Good for 0-100% humidity readings with 2-5% accuracy

Good for -40 to 125°C temperature readings ±0.5°C accuracy

No more than 0.5 Hz sampling rate (once every 2 seconds)

Body size 15.1mm x 25mm x 7.7mm

4 pins with 0.1" spacing

[링크 : https://learn.adafruit.com/dht/overview]


[링크 : http://cdn.sparkfun.com/datasheets/Sensors/Weather/RHT03.pdf]


RHT03 (also known by DHT-22)

[링크 : https://www.sparkfun.com/products/10167]


AM2302가 DHT22 대응인 듯

그냥 .. DHT11만 보더라도 상당히 불안정하게 값이 읽혀온다.

[링크 : http://www.kandrsmith.org/RJS/Misc/calib_dht22_dht11_sht71.html] 벤치마크?



아무튼.. DHT-11은 저가형에 정밀하지 못한 녀석

DHT-22/RHT03은 정밀한 녀석으로 결론...

Posted by 구차니
Linux API/linux2015. 10. 13. 16:09


ITIMER_REAL

decrements in real time, and delivers SIGALRM upon expiration.

실시간으로 감소하고 만료시 SIGALRM을 전송한다.


ITIMER_VIRTUAL

decrements only when the process is executing, and delivers SIGVTALRM upon expiration.

프로세스가 실행중잉 동안만 감소하고 만료시 SIGVTALRM을 전송한다.


ITIMER_PROF

decrements both when the process executes and when the system is executing on behalf of the process. Coupled with ITIMER_VIRTUAL, this timer is usually used to profile the time spent by the application in user and kernel space. SIGPROF is delivered upon expiration.

프로세스가 실행중이거나 시스템이 프로세스 대신 작동하는 동안에도 감소한다. ITIMER_VITUAL과 결합하여 유저 시간과 커널 시간을 프로파일링 하는데 사용된다. SIGPROF가 만료시 전송한다.


Timer values are defined by the following structures:

struct itimerval {

    struct timeval it_interval; /* next value */

    struct timeval it_value;    /* current value */

};


struct timeval {

    time_t      tv_sec;         /* seconds */

    suseconds_t tv_usec;        /* microseconds */

};


The function getitimer() fills the structure pointed to by curr_value with the current setting for the timer specified by which (one of ITIMER_REAL, ITIMER_VIRTUAL, or ITIMER_PROF). The element it_value is set to the amount of time remaining on the timer, or zero if the timer is disabled. Similarly, it_interval is set to the reset value.

it_value 값은 타이머의 남은 값을 설정하거나 타이머를 사용하지 않기 위해 0으로 설정한다. 유사하게 it_interval는 초기화 값을 설정한다.

The function setitimer() sets the specified timer to the value in new_value. If old_value is non-NULL, the old value of the timer is stored there.


Timers decrement from it_value to zero, generate a signal, and reset to it_interval. A timer which is set to zero (it_value is zero or the timer expires and it_interval is zero) stops.

it_value로 부터 0으로 타이머가 감소하고, 시그널을 생성하고, it_interval로 초기화 한다. 타이머가 0으로 설정되면 정지한다(it_value가 0이거나 타이머가 만료되고 it_interval이 0일 경우)


Both tv_sec and tv_usec are significant in determining the duration of a timer.


Timers will never expire before the requested time, but may expire some (short) time afterward, which depends on the system timer resolution and on the system load; see time(7). (But see BUGS below.) Upon expiration, a signal will be generated and the timer reset. If the timer expires while the process is active (always true for ITIMER_VIRTUAL) the signal will be delivered immediately when generated. Otherwise the delivery will be offset by a small time dependent on the system loading.

[링크 : http://linux.die.net/man/2/setitimer]


그래서 둘다 설정하지 않으면 멈추는 거구나..

다만. it_value의 값은 초기 1회에 대한 타이머이고

it_interval의 값은 2회 부터의 값에 대한 타이머가 된다.

timer.it_value.tv_sec = 0;

timer.it_value.tv_usec = 250000;

timer.it_interval.tv_sec = 0;

timer.it_interval.tv_usec = 250000;


[링크 : http://linuxspot.tistory.com/28] 


[링크 : https://kldp.org/node/132754]

[링크 : http://manofpro.tistory.com/290]

[링크 : http://forum.falinux.com/zbxe/index.php?document_srl=413903]


[링크 : http://www.joinc.co.kr/modules/moniwiki/wiki.php/article/Timesr_in_Linux]

'Linux API > linux' 카테고리의 다른 글

select()  (0) 2015.10.26
mmap / ioremap  (0) 2015.10.21
리눅스 모듈 - 세마포어 / 뮤텍스  (0) 2015.10.21
linux kernel module module_init() 매크로  (0) 2015.10.21
clock_gettime  (0) 2015.08.09
Posted by 구차니
embeded/Cortex-M3 Ti2015. 10. 13. 11:47

lm3s617외에 같은 클래스에서도 동일한 녀석으로 쓸수 있으려나?
코드를 보니.. 메인을 장악해버려서 다른 프로그램의 하위 시스템으로 넣기에는 엄청난 수정이 필요 할지도..


[링크 : http://www.ti.com/lit/ug/spmu026a/spmu026a.pdf] Stellaris® Stepper Motor Reference Design Kit

[링크 : http://www.ti.com/lit/ds/symlink/lm3s617.pdf] LM3S617

[링크 : http://www.ti.com/product/LM3S617/description]

    [링크 : http://www.ti.com/tool/sw-rdk-stepper-gui]

    [링크 : http://www.ti.com/tool/sw-rdk-stepper]

'embeded > Cortex-M3 Ti' 카테고리의 다른 글

lm3s1607 / lm3s811 비교  (0) 2015.11.03
bitband 고찰..  (0) 2015.10.23
lm3s spi / ssi  (0) 2015.10.06
lm3s stellarisware SPI  (0) 2015.10.05
cortex-m3 ROM direct call  (0) 2015.09.25
Posted by 구차니
이론 관련/전기 전자2015. 10. 13. 10:55

linux/os의 PID가 아님

 

P: Proportinal(비례) 

I: Integral(적분) 

D: Differential(미분) 

 

 

[링크 : https://ko.wikipedia.org/wiki/PID_제어기]

[링크 : http://www.ktechno.co.kr/pictech/motor05.html]

 

소스구현

[링크 : http://enginius.tistory.com/46]

[링크 : http://magicom9.tistory.com/3]

 

+

2022.04.01

[링크 : https://throwexception.tistory.com/851]

 

'이론 관련 > 전기 전자' 카테고리의 다른 글

디지털 서보(?)  (0) 2015.11.24
DMOS?  (0) 2015.10.20
전류제어  (0) 2015.09.11
디지털 필터 - FIR / IIR  (0) 2015.01.23
역률이 모야?  (2) 2011.08.04
Posted by 구차니
embeded/raspberry pi2015. 10. 12. 16:42

sparkfun의 아두이노용 드라이버를 라즈베리 파이/wiring pi로 포팅한 버전



[링크 : https://github.com/blerchin/dSPIN_raspi]

[링크 : https://github.com/sparkfun/L6470-AutoDriver/]



몰랐는데...

wiringpi가 아두이노를 닮은건가.. 그 반대일려나?

함수가 상당수 호환된다?


아두이노가.. 2005년 wiring 이라는 보드로 시작해서..

거기껄 끌어 온거니.. wiringpi가 더 나중일 것으로 생각된다.

---

void digitalWrite (int pin, int value) ;

[링크 : http://wiringpi.com/reference/core-functions/]


digitalWrite(pin, value)

[링크 : https://www.arduino.cc/en/Reference/DigitalWrite]

Posted by 구차니
Programming/C Win32 MFC2015. 10. 12. 10:45

소스상으로는 "%d "와 "%d\n"으로

1바이트 차이일텐데... 이상하게 cpu 사용률이 다르게 나온다.

$ cat sp.c

#include <stdio.h>

#include <omp.h>


int main(int argc, char **argv)

{

        int a = 0;


        for(;;)

        {

        a++;

//      printf("%d ",a);

        printf("%d\n",a);

        }


        return 0;

}



물론. -fopenmp의 영향은 받지 않는다.

$ gcc -fopenmp -o b.out sp.c 


printf("%d ",a);

를 활성화


printf("%d\n",a);

를 활성화


fflush(stdout);

을 추가해서 해보니 비슷하게 나온다... printf()가 bufferd output인데

\n에서 강제로 fflush하게 하는건가..

[링크 : http://stackoverflow.com/.../why-does-stdout-need-explicit-flushing-when-redirected-to-file]

'Programming > C Win32 MFC' 카테고리의 다른 글

가변 매크로 __VA_ARGS__  (0) 2016.03.18
#import ?  (0) 2015.12.21
rand()와 RAND_MAX  (0) 2015.10.05
Cppcheck  (0) 2015.09.30
void형 포인터 ++  (0) 2015.07.14
Posted by 구차니
Programming/openMP2015. 10. 12. 09:23

흐음..

다음단계에서 확장되나... 소스레벨에서는 차이가 별로 안나네


-E



-S

먼가 우르르 나오는데 어셈이랑 안친해서 ㅠㅠ

아무튼 GOMP 어쩌구가 보이긴 하네..



'Programming > openMP' 카테고리의 다른 글

openMP lock/unlock  (0) 2015.11.10
openmp 관련 정리글(win32)  (0) 2015.10.08
openmp 테스트 on rpi  (0) 2015.10.06
openCV + openMP  (0) 2015.09.30
openMP affinity 관련..  (0) 2015.07.23
Posted by 구차니