mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 00:43:54 +08:00
cleanups
This commit is contained in:
@@ -54,8 +54,8 @@ static void* rear_thread(void *arg) {
|
||||
CameraState* s = (CameraState*)arg;
|
||||
|
||||
cv::VideoCapture cap_rear(1); // road
|
||||
cap_rear.set(cv::CAP_PROP_FRAME_WIDTH, 1280);
|
||||
cap_rear.set(cv::CAP_PROP_FRAME_HEIGHT, 720);
|
||||
cap_rear.set(cv::CAP_PROP_FRAME_WIDTH, 853);
|
||||
cap_rear.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
|
||||
cap_rear.set(cv::CAP_PROP_FPS, s->fps);
|
||||
cap_rear.set(cv::CAP_PROP_AUTOFOCUS, 0); // off
|
||||
cap_rear.set(cv::CAP_PROP_FOCUS, 0); // 0 - 255?
|
||||
@@ -66,9 +66,13 @@ static void* rear_thread(void *arg) {
|
||||
size.width = s->ci.frame_width;
|
||||
|
||||
// transforms calculation see tools/webcam/warp_vis.py
|
||||
float ts[9] = {1.00220264, 0.0, -59.40969163,
|
||||
0.0, 1.00220264, 76.20704846,
|
||||
float ts[9] = {1.50330396, 0.0, -59.40969163,
|
||||
0.0, 1.50330396, 76.20704846,
|
||||
0.0, 0.0, 1.0};
|
||||
// if camera upside down:
|
||||
// float ts[9] = {-1.50330396, 0.0, 1223.4,
|
||||
// 0.0, -1.50330396, 797.8,
|
||||
// 0.0, 0.0, 1.0};
|
||||
const cv::Mat transform = cv::Mat(3, 3, CV_32F, ts);
|
||||
|
||||
if (!cap_rear.isOpened()) {
|
||||
@@ -126,8 +130,8 @@ void front_thread(CameraState *s) {
|
||||
int err;
|
||||
|
||||
cv::VideoCapture cap_front(2); // driver
|
||||
cap_front.set(cv::CAP_PROP_FRAME_WIDTH, 1280);
|
||||
cap_front.set(cv::CAP_PROP_FRAME_HEIGHT, 720);
|
||||
cap_front.set(cv::CAP_PROP_FRAME_WIDTH, 853);
|
||||
cap_front.set(cv::CAP_PROP_FRAME_HEIGHT, 480);
|
||||
cap_front.set(cv::CAP_PROP_FPS, s->fps);
|
||||
// cv::Rect roi_front(320, 0, 960, 720);
|
||||
|
||||
@@ -136,9 +140,13 @@ void front_thread(CameraState *s) {
|
||||
size.width = s->ci.frame_width;
|
||||
|
||||
// transforms calculation see tools/webcam/warp_vis.py
|
||||
float ts[9] = {0.94713656, 0.0, -30.16740088,
|
||||
0.0, 0.94713656, 91.030837,
|
||||
float ts[9] = {1.42070485, 0.0, -30.16740088,
|
||||
0.0, 1.42070485, 91.030837,
|
||||
0.0, 0.0, 1.0};
|
||||
// if camera upside down:
|
||||
// float ts[9] = {-1.42070485, 0.0, 1182.2,
|
||||
// 0.0, -1.42070485, 773.0,
|
||||
// 0.0, 0.0, 1.0};
|
||||
const cv::Mat transform = cv::Mat(3, 3, CV_32F, ts);
|
||||
|
||||
if (!cap_front.isOpened()) {
|
||||
@@ -266,4 +274,4 @@ void cameras_run(DualCameraState *s) {
|
||||
err = pthread_join(rear_thread_handle, NULL);
|
||||
assert(err == 0);
|
||||
cameras_close(s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,8 +189,13 @@ persistent_processes = [
|
||||
'thermald',
|
||||
'logmessaged',
|
||||
'ui',
|
||||
'uploader',
|
||||
]
|
||||
|
||||
if not WEBCAM:
|
||||
persistent_processes += [
|
||||
'uploader',
|
||||
]
|
||||
|
||||
if ANDROID:
|
||||
persistent_processes += [
|
||||
'logcatd',
|
||||
@@ -201,7 +206,6 @@ if ANDROID:
|
||||
car_started_processes = [
|
||||
'controlsd',
|
||||
'plannerd',
|
||||
'loggerd',
|
||||
'radard',
|
||||
'dmonitoringd',
|
||||
'calibrationd',
|
||||
@@ -209,13 +213,19 @@ car_started_processes = [
|
||||
'camerad',
|
||||
'modeld',
|
||||
'proclogd',
|
||||
'ubloxd',
|
||||
'locationd',
|
||||
]
|
||||
if WEBCAM:
|
||||
|
||||
if not WEBCAM:
|
||||
car_started_processes += [
|
||||
'loggerd',
|
||||
'ubloxd',
|
||||
]
|
||||
else:
|
||||
car_started_processes += [
|
||||
'dmonitoringmodeld',
|
||||
]
|
||||
|
||||
if ANDROID:
|
||||
car_started_processes += [
|
||||
'sensord',
|
||||
|
||||
@@ -23,14 +23,15 @@ git clone https://github.com/commaai/openpilot.git
|
||||
```
|
||||
## Build openpilot for webcam
|
||||
```
|
||||
cd ~/openpilot
|
||||
scons use_webcam=1
|
||||
cd ~/openpilot
|
||||
# check out selfdrive/camerad/cameras/camera_webcam.cc line72&146 if any camera is upside down
|
||||
scons use_webcam=1
|
||||
touch prebuilt
|
||||
```
|
||||
## Connect the hardwares
|
||||
```
|
||||
# Connect the road facing camera first, then the driver facing camera
|
||||
# (default indexes are 1 and 2; can be modified in selfdrive/camerad/cameras/camera_webcam.cc)
|
||||
# (default indexes are 1 and 2; can be modified in selfdrive/camerad/cameras/camera_webcam.cc)
|
||||
# Connect your computer to panda
|
||||
```
|
||||
## GO
|
||||
|
||||
@@ -5,7 +5,7 @@ import numpy as np
|
||||
eon_focal_length = 910.0 # pixels
|
||||
eon_dcam_focal_length = 860.0 # pixels
|
||||
|
||||
webcam_focal_length = 908.0 # pixels
|
||||
webcam_focal_length = -908.0/1.5 # pixels
|
||||
|
||||
eon_intrinsics = np.array([
|
||||
[eon_focal_length, 0., 1164/2.],
|
||||
@@ -18,8 +18,8 @@ eon_dcam_intrinsics = np.array([
|
||||
[ 0, 0, 1]])
|
||||
|
||||
webcam_intrinsics = np.array([
|
||||
[webcam_focal_length, 0., 1280/2.],
|
||||
[ 0., webcam_focal_length, 720/2.],
|
||||
[webcam_focal_length, 0., 1280/2/1.5],
|
||||
[ 0., webcam_focal_length, 720/2/1.5],
|
||||
[ 0., 0., 1.]])
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -30,8 +30,8 @@ if __name__ == "__main__":
|
||||
print("trans_webcam_to_eon_front:\n", trans_webcam_to_eon_front)
|
||||
|
||||
cap = cv2.VideoCapture(1)
|
||||
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
|
||||
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
|
||||
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 853)
|
||||
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
|
||||
|
||||
while (True):
|
||||
ret, img = cap.read()
|
||||
|
||||
Reference in New Issue
Block a user