'Programming'에 해당되는 글 1762건

  1. 2019.05.24 cpp stringstream << 연산자
  2. 2019.05.24 while(-1) 이 될까?
  3. 2019.05.22 R rJava 설정
  4. 2019.05.15 node.js express 301 redirect
  5. 2019.05.15 python pdb를 이용한 디버깅
  6. 2019.05.15 anaconda(python)
  7. 2019.05.14 파이썬 vscode 디버깅 하기
  8. 2019.05.10 opencv face detect
  9. 2019.05.10 vscode python3 opencv lint
  10. 2019.05.10 glfw3 in ubuntu 19.04
Programming/C++ STL2019. 5. 24. 15:43

어떻게 보면.. scanf를 좀 편리하게 해주는 cpp용 연산자라고 보면 되려나?

 

[링크 : http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/]

 

string str_sensor_data(mesg);
stringstream stream(str_sensor_data);
for(int i=0;i<5;i++){

    stream >> sensor_data[i]; 

}

[링크 : http://youngmok.com/udp-server-c-class-listening-thread/]

'Programming > C++ STL' 카테고리의 다른 글

cpp 부모타입으로 업 캐스팅 된 객체의 원래 클래스 알기  (0) 2021.09.30
cpp string 관련  (0) 2019.06.10
c++ 함수 인자 기본값  (0) 2017.11.08
cpp string compare 와 ==  (0) 2017.01.31
cpp this  (0) 2016.07.18
Posted by 구차니
Programming/C Win32 MFC2019. 5. 24. 12:18

코드 분석하다 보니 어떻게 작동할지 몰라서 해보니

헐.. while(0) 이냐 !0 이냐 정도로 밖에 작동하지 않네

예제 소스가 이상한 조건문이 되어버렸네...

 

client_sock에 -1이 들어와도 while은 중단되지 않고 0일때만 중단되는데

그러면 if(client_sock < 0)은 <=0이 아니라 들어갈 방법이 없네?

while( (client_sock = accept(socket_desc, (struct sockaddr *)&client, (socklen_t*)&c)) )
{
puts("Connection accepted");

pthread_t sniffer_thread;
new_sock = malloc(1);
*new_sock = client_sock;

if( pthread_create( &sniffer_thread , NULL ,  connection_handler , (void*) new_sock) < 0)
{
perror("could not create thread");
return 1;
}

//Now join the thread , so that we dont terminate before the thread
//pthread_join( sniffer_thread , NULL);
puts("Handler assigned");
}

if (client_sock < 0)
{
perror("accept failed");
return 1;
}

[링크 : https://www.binarytides.com/server-client-example-c-sockets-linux/]

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

vkey win32 / linux  (0) 2021.04.30
strptime  (0) 2021.02.17
c언어용 JSON 라이브러리 목록  (0) 2018.10.23
uuid in c  (0) 2018.10.22
엔디안 급 멘붕..  (0) 2018.05.29
Posted by 구차니
Programming/R2019. 5. 22. 15:01

이제 R까지 해야하나.. ㅠㅠ

java가 있는데 인식을 못하고 뻘짓할때 이거 해주고

R 실행하면 되는 듯

 

sudo R CMD javareconf

[링크 : https://askubuntu.com/questions/1069463/not-able-to-install-rjava-in-r-ubuntu-18-04]

Posted by 구차니
Programming/node.js2019. 5. 15. 13:38

흐음.. 캐싱할때 이걸 어떻게 상태로 캐싱을 해놓으면 되려나..

 

app.use(function forceLiveDomain(req, res, next) {
  // Don't allow user to hit Heroku now that we have a domain
  var host = req.get('Host');
  if (host === 'serviceworker-cookbook.herokuapp.com') {
    return res.redirect(301, 'https://serviceworke.rs/' + req.originalUrl);
  }
  return next();
});

 

[링크 : https://davidwalsh.name/express-redirect-301]

[링크 : https://stackoverflow.com/questions/7450940/automatic-https-connection-redirect-with-node-js-express]

 

res.redirect([status,] path)
Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code . If not specified, status defaults to “302 “Found”.

[링크 : https://expressjs.com/ko/4x/api.html#res.redirect]

'Programming > node.js' 카테고리의 다른 글

npm-run-all 병렬 빌드 (실패)  (0) 2019.05.29
pdf 내용 추출  (0) 2019.05.27
node.js 항목 확인  (0) 2019.04.23
proxy error: Error: write after end  (0) 2019.04.23
node.js 시그널 핸들링과 reload  (0) 2019.04.23
Posted by 구차니

함수 같은녀석들 어떻게 처리하나 궁금했는데

인터랙티브 하게 디버깅 간으한 자체 모듈이 있는 듯

 

2.x 대에도 있고 3.x대에도 있으니 걱정없고

아래처럼 인터프리터에서 pdb를 불러와 pdb.run()을 통해 해당 모듈을 테스트 할 수 있고

>>> import pdb
>>> import mymodule
>>> pdb.run('mymodule.test()')
> (0)?()
(Pdb) continue
> (1)?()
(Pdb) continue
NameError: 'spam'
> (1)?()
(Pdb)

 

아니면 -m pdb로 모듈을 불러 특정 스크립트를 실행하는 것도 방법인듯

python3 -m pdb myscript.py

[링크 : https://docs.python.org/3.7/library/pdb.html]

[링크 : https://www.digitalocean.com/community/tutorials/how-to-use-the-python-debugger]

'Programming > python(파이썬)' 카테고리의 다른 글

ubuntu에서 python으로 postgres 접속하기  (0) 2019.06.24
python pip 특정 버전 설치하기  (0) 2019.06.18
anaconda(python)  (0) 2019.05.15
파이썬 vscode 디버깅 하기  (0) 2019.05.14
python3 import cv2  (0) 2019.05.09
Posted by 구차니

 

[링크 : https://www.anaconda.com/distribution/]

 

[링크 : https://wikidocs.net/22896]

[링크 : https://snowdeer.github.io/python/2017/11/07/python-vs-anaconda/]

[링크 : https://dojang.io/mod/page/view.php?id=2456]

 

jupyter

[링크 : https://dojang.io/mod/page/view.php?id=2457]

'Programming > python(파이썬)' 카테고리의 다른 글

python pip 특정 버전 설치하기  (0) 2019.06.18
python pdb를 이용한 디버깅  (0) 2019.05.15
파이썬 vscode 디버깅 하기  (0) 2019.05.14
python3 import cv2  (0) 2019.05.09
python pylint @ vscode  (0) 2019.05.09
Posted by 구차니

인터프리터니까 한줄씩 하면 되긴 하지만

그래도 함수 쓰면 영 안되서 디버거를 쓸수 있는게 아무래도 유리하니까...

 

[링크 : https://docs.microsoft.com/ko-kr/visualstudio/python/debugging-python-in-visual-studio?view=vs-2019]

[링크 : http://egloos.zum.com/mcchae/v/11262544]

[링크 : http://pythonstudy.xyz/python/article/505-Python-디버깅-PDB]

'Programming > python(파이썬)' 카테고리의 다른 글

python pdb를 이용한 디버깅  (0) 2019.05.15
anaconda(python)  (0) 2019.05.15
python3 import cv2  (0) 2019.05.09
python pylint @ vscode  (0) 2019.05.09
python wxpython  (0) 2019.05.08
Posted by 구차니
Programming/openCV2019. 5. 10. 19:17

 

 

import cv2

 

dirname = '/home/user/.local/lib/python3.6/site-packages/cv2/data/'

 

face_cascade = cv2.CascadeClassifier(dirname + 'haarcascade_frontalface_default.xml')

eye_cascade = cv2.CascadeClassifier(dirname + 'haarcascade_eye.xml')

 

cam = cv2.VideoCapture(0)

cam.set(3, 160) # CV_CAP_PROP_FRAME_WIDTH

cam.set(4, 120) # CV_CAP_PROP_FRAME_HEIGHT

cam.set(5, 60) # CV_CAP_PROP_FPS

print(cam.get(3))

print(cam.get(4))

print(cam.get(5))

 

while True:

ret_val, img = cam.read()

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

 

faces = face_cascade.detectMultiScale(gray, 1.3, 5)

print(faces)

for (x, y, w, h) in faces:

img = cv2.rectangle(img, (x, y), (x+w, y+h), (255, 0, 0), 2)

roi_gray = gray[y:y+h, x:x+w]

roi_color = img[y:y+h, x:x+w]

eyes = eye_cascade.detectMultiScale(roi_gray)

for (ex, ey, ew, eh) in eyes:

cv2.rectangle(roi_color, (ex, ey), (ex+ew, ey+eh), (0, 255, 0), 2)

 

cv2.imshow("Cam Viewer", img)

cv2.imshow("Cam Viewer gray", gray)

if cv2.waitKey(1) == 27:

break

 

[링크 : https://opencv-python-tutroals.readthedocs.io/.../py_face_detection/py_face_detection.html]

[링크 : https://stackoverflow.com/questions/30508922/error-215-empty-in-function-detectmultiscale]

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

virtual mouse  (0) 2022.01.25
opencv-3.4.0 어플리케이션 빌드  (0) 2021.01.14
vscode python3 opencv lint  (0) 2019.05.10
opencv cannyedge  (0) 2019.01.16
opencv 원 추정  (0) 2019.01.16
Posted by 구차니
Programming/openCV2019. 5. 10. 19:05

 

{

"python.linting.pylintArgs": ["--extension-pkg-whitelist=cv2"]

}

[ : https://github.com/Microsoft/vscode-python/issues/2879]

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

opencv-3.4.0 어플리케이션 빌드  (0) 2021.01.14
opencv face detect  (0) 2019.05.10
opencv cannyedge  (0) 2019.01.16
opencv 원 추정  (0) 2019.01.16
OpenCV 분산처리  (0) 2018.04.25
Posted by 구차니
Programming/openGL2019. 5. 10. 08:34

원인은 모르겠는데.. 링크할때 파일명이랑 순서가 영향을 주네? 머지?

 

$ sudo apt-get install libglfw3-dev libglfw3

$ vi glfw.c

#include <GLFW/glfw3.h>
#include 
#include 
static void error_callback(int error, const char* description)
{
    fputs(description, stderr);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
    if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
        glfwSetWindowShouldClose(window, GL_TRUE);
}
int main(void)
{
    GLFWwindow* window;
    glfwSetErrorCallback(error_callback);
    if (!glfwInit())
        exit(EXIT_FAILURE);
    window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }
    glfwMakeContextCurrent(window);
    glfwSetKeyCallback(window, key_callback);
    while (!glfwWindowShouldClose(window))
    {
        float ratio;
        int width, height;
        glfwGetFramebufferSize(window, &width, &height);
        ratio = width / (float) height;
        glViewport(0, 0, width, height);
        glClear(GL_COLOR_BUFFER_BIT);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-ratio, ratio, -1.f, 1.f, 1.f, -1.f);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glRotatef((float) glfwGetTime() * 50.f, 0.f, 0.f, 1.f);
        glBegin(GL_TRIANGLES);
        glColor3f(1.f, 0.f, 0.f);
        glVertex3f(-0.6f, -0.4f, 0.f);
        glColor3f(0.f, 1.f, 0.f);
        glVertex3f(0.6f, -0.4f, 0.f);
        glColor3f(0.f, 0.f, 1.f);
        glVertex3f(0.f, 0.6f, 0.f);
        glEnd();
        glfwSwapBuffers(window);
        glfwPollEvents();
    }
    glfwDestroyWindow(window);
    glfwTerminate();
    exit(EXIT_SUCCESS);
}

$ gcc glfw.c -lglfw -lGL

 

[링크 : https://www.glfw.org/docs/3.0/quick.html]

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

gl model view projection mat  (0) 2019.05.29
gluPerspective()  (0) 2019.05.28
openGL vao(Vertex Array Object)  (0) 2019.05.07
glfw - gl framework  (0) 2019.05.07
openGL 3.0 tutorial  (0) 2019.05.07
Posted by 구차니