Skip to content
phuonglab edited this page Aug 8, 2021 · 5 revisions

Embedded Linux

1. ======= lighttpd ==========

  • Enable ssl

    cd /etc/lighttpd/certs
    openssl req -new -x509 -keyout lighttpd.pem -out lighttpd.pem -days 365 -nodes
    chmod 400 lighttpd.pem
    ⇒ Change common name during generate lighttpd.pem key to matching domain name 192.168.123.196
  • Then edit /etc/lighttpd/lighttpd.conf and add:

    $SERVER["socket"] == ":443" {
      ssl.engine = "enable" 
      ssl.pemfile = "/etc/lighttpd/certs/lighttpd.pem" 
    }
  • Curl test:

    echo "" | openssl s_client -servername 192.168.123.196 -connect 192.168.123.196:443 2>/dev/null </dev/null |  sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > client.key
    curl -v --cacert client.key https://192.168.123.196:443/deviceInfo 

2. ======= IDE ==========

2.1. CLion: A Cross-Platform IDE for C and C++ by JetBrains

3. ======= Gstreamer and OpenCV ==========

  • Server

    • Format I420

      gst-launch-1.0 v4l2src device=/dev/video0 ! \
      	video/x-raw, format=I420, \
      	width=640, height=480, framerate=15/1 ! \
      	videoconvert ! videoscale ! video/x-raw, width=320, height=240 ! \
      	rtpvrawpay ! udpsink host=127.0.0.1 port=5002
    • Format RGB

      gst-launch-1.0 v4l2src device=/dev/video0 ! \
      	video/x-raw,format=RGB, \
      	width=640,height=480,framerate=15/1 ! \
      	videoconvert ! videoscale ! video/x-raw, width=320, height=240 ! \
      	rtpvrawpay ! udpsink host=127.0.0.1 port=5002 sync=false
    • Use cv::VideoWriter

      std::string gstreamer_pipeline(int device, int capture_width, int capture_height, int framerate, int display_width, int display_height) {
          return
                  " v4l2src device=/dev/video"+ std::to_string(device) + " !"
                  " video/x-raw, format=BGR, "
                  " width=(int)" + std::to_string(capture_width) + ","
                  " height=(int)" + std::to_string(capture_height) + ","
                  " framerate=(fraction)" + std::to_string(framerate) +"/1 !"
                  " videoconvert ! videoscale !"
                  " video/x-raw,"
                  " width=(int)" + std::to_string(display_width) + ","
                  " height=(int)" + std::to_string(display_height) + " ! appsink";
      }
      
      cv::VideoWriter out("appsrc ! videoconvert ! video/x-raw, format=I420, width=320, height=240, framerate=15/1 ! rtpvrawpay ! udpsink host=127.0.0.1 port=5002",
                                                  cv::CAP_GSTREAMER,0,15,cv::Size(320,240));

4. Client

gst-launch-1.0 udpsrc port="5002" \
	caps="application/x-rtp, media=(string)video, encoding-name=(string)RAW, sampling=(string)YCbCr-4:2:0, \
	width=(string)320, height=(string)240, framerate=15/1 " ! \
	rtpjitterbuffer ! rtpvrawdepay ! queue ! \
	videoconvert ! videoscale ! video/x-raw, width=320, height=240 ! autovideosink sync=false
gst-launch-1.0 udpsrc port="5002" \
	caps="application/x-rtp, media=(string)video, playload=(int)96 , clock-rate=(int)90000, \
	encoding-name=(string)RAW, sampling=(string)RGB, depth=(string)8, \
	width=(string)320, height=(string)240, framerate=15/1" ! \
	rtpjitterbuffer ! rtpvrawdepay ! queue ! \
	videoconvert ! videoscale ! video/x-raw, width=320, height=240 ! autovideosink sync=false

Clone this wiki locally