Skip to content

Commit

Permalink
Homography Images
Browse files Browse the repository at this point in the history
  • Loading branch information
Shashank-Prakash9 committed Mar 14, 2023
1 parent 692f673 commit af29a6c
Show file tree
Hide file tree
Showing 38 changed files with 71 additions and 25 deletions.
13 changes: 2 additions & 11 deletions capture_save.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cv2

key = cv2. waitKey(1)
webcam = cv2.VideoCapture('rtsp://admin:[email protected]/4') #replace 0 with the IP URL of the streaming camera
webcam = cv2.VideoCapture('rtsp://admin:[email protected]/1') #replace 0 with the IP URL of the streaming camera
while True:
try:
check, frame = webcam.read()
Expand All @@ -16,16 +16,7 @@
img_new = cv2.imshow("Captured Image", img_new)
cv2.waitKey(1650)
cv2.destroyAllWindows()
print("Processing image...")
img_ = cv2.imread('saved_img.jpg', cv2.IMREAD_ANYCOLOR)
print("Converting RGB image to grayscale...")
gray = cv2.cvtColor(img_, cv2.COLOR_BGR2GRAY)
print("Converted RGB image to grayscale...")
print("Resizing image to 28x28 scale...")
img_ = cv2.resize(gray,(28,28))
print("Resized...")
img_resized = cv2.imwrite(filename='saved_img-final.jpg', img=img_)
print("Image saved!")


break
elif key == ord('q'):
Expand Down
48 changes: 46 additions & 2 deletions catkin_ws/build/CMakeCache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,27 @@
# EXTERNAL cache entries
########################

//Build debug target (ON) or release (OFF)
BUILD_DEBUG_TARGET:BOOL=ON

//Builds the googlemock subproject
BUILD_GMOCK:BOOL=ON

//Build sick_scan library with function hiding except for SickScanApi-functions
// (ON) or without function hiding (OFF)
BUILD_LIB_HIDE_FUNCTIONS:BOOL=OFF

//Build dynamically-linked binaries
BUILD_SHARED_LIBS:BOOL=ON

//Build sick_scan with LDMRS support (ON, libsick_ldmrs from https://github.com/SICKAG/libsick_ldmrs
// required) or without LDMRS support (OFF)
BUILD_WITH_LDMRS_SUPPORT:BOOL=ON

//Build sick_scan with SCANSEGMENT_XD support (ON) or without SCANSEGMENT_XD
// support (OFF)
BUILD_WITH_SCANSEGMENT_XD_SUPPORT:BOOL=ON

//List of ';' separated packages to exclude
CATKIN_BLACKLIST_PACKAGES:STRING=

Expand Down Expand Up @@ -306,6 +321,10 @@ EMPY_EXECUTABLE:FILEPATH=EMPY_EXECUTABLE-NOTFOUND
//Empy script
EMPY_SCRIPT:STRING=/usr/lib/python3/dist-packages/em.py

//Build emulator for offline and unittests (ON) or without emulator
// (OFF)
ENABLE_EMULATOR:BOOL=OFF

//Path to a library.
GMOCK_LIBRARY:FILEPATH=GMOCK_LIBRARY-NOTFOUND

Expand Down Expand Up @@ -352,6 +371,9 @@ LSB_RELEASE_EXECUTABLE:FILEPATH=/usr/bin/lsb_release
//Path to a program.
NOSETESTS:FILEPATH=/usr/bin/nosetests3

//pkg-config executable
PKG_CONFIG_EXECUTABLE:FILEPATH=/usr/bin/pkg-config

//Path to a program.
PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python3

Expand Down Expand Up @@ -397,6 +419,9 @@ SETUPTOOLS_DEB_LAYOUT:BOOL=ON
//Name of the computer/site where compile is being run
SITE:STRING=rbccps-2080

//The directory containing a CMake configuration file for SickLDMRS.
SickLDMRS_DIR:PATH=SickLDMRS_DIR-NOTFOUND

//LSB Distrib tag
UBUNTU:BOOL=TRUE

Expand Down Expand Up @@ -433,6 +458,15 @@ cpp_common_DIR:PATH=/opt/ros/noetic/share/cpp_common/cmake
//The directory containing a CMake configuration file for cv_bridge.
cv_bridge_DIR:PATH=/opt/ros/noetic/share/cv_bridge/cmake

//The directory containing a CMake configuration file for diagnostic_msgs.
diagnostic_msgs_DIR:PATH=/opt/ros/noetic/share/diagnostic_msgs/cmake

//The directory containing a CMake configuration file for diagnostic_updater.
diagnostic_updater_DIR:PATH=/opt/ros/noetic/share/diagnostic_updater/cmake

//The directory containing a CMake configuration file for dynamic_reconfigure.
dynamic_reconfigure_DIR:PATH=/opt/ros/noetic/share/dynamic_reconfigure/cmake

//The directory containing a CMake configuration file for gencpp.
gencpp_DIR:PATH=/opt/ros/noetic/share/gencpp/cmake

Expand Down Expand Up @@ -510,7 +544,7 @@ interactive_markers_DIR:PATH=/opt/ros/noetic/share/interactive_markers/cmake
laser_geometry_DIR:PATH=/opt/ros/noetic/share/laser_geometry/cmake

//Path to a library.
lib:FILEPATH=/opt/ros/noetic/lib/libroscpp_serialization.so
lib:FILEPATH=/opt/ros/noetic/lib/libtf2.so

//The directory containing a CMake configuration file for map_msgs.
map_msgs_DIR:PATH=/opt/ros/noetic/share/map_msgs/cmake
Expand Down Expand Up @@ -581,6 +615,12 @@ selected_points_publisher_SOURCE_DIR:STATIC=/home/rbccps/Desktop/RBCCPS2023/catk
//The directory containing a CMake configuration file for sensor_msgs.
sensor_msgs_DIR:PATH=/opt/ros/noetic/share/sensor_msgs/cmake

//Value Computed by CMake
sick_scan_BINARY_DIR:STATIC=/home/rbccps/Desktop/RBCCPS2023/catkin_ws/build/sick_scan_xd

//Value Computed by CMake
sick_scan_SOURCE_DIR:STATIC=/home/rbccps/Desktop/RBCCPS2023/catkin_ws/src/sick_scan_xd

//The directory containing a CMake configuration file for std_msgs.
std_msgs_DIR:PATH=/opt/ros/noetic/share/std_msgs/cmake

Expand Down Expand Up @@ -765,7 +805,7 @@ CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_NM
CMAKE_NM-ADVANCED:INTERNAL=1
//number of local generators
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=6
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=5
//ADVANCED property for variable: CMAKE_OBJCOPY
CMAKE_OBJCOPY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_OBJDUMP
Expand Down Expand Up @@ -810,6 +850,8 @@ CMAKE_UNAME:INTERNAL=/usr/bin/uname
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1
//Details about finding PY_em
FIND_PACKAGE_MESSAGE_DETAILS_PY_em:INTERNAL=[/usr/lib/python3/dist-packages/em.py][v()]
//Details about finding PkgConfig
FIND_PACKAGE_MESSAGE_DETAILS_PkgConfig:INTERNAL=[/usr/bin/pkg-config][v0.29.1()]
//Details about finding PythonInterp
FIND_PACKAGE_MESSAGE_DETAILS_PythonInterp:INTERNAL=[/usr/bin/python3][v3.8.10()]
//Details about finding Threads
Expand Down Expand Up @@ -842,6 +884,8 @@ GTEST_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
GTEST_MAIN_LIBRARY-ADVANCED:INTERNAL=1
//ADVANCED property for variable: GTEST_MAIN_LIBRARY_DEBUG
GTEST_MAIN_LIBRARY_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PKG_CONFIG_EXECUTABLE
PKG_CONFIG_EXECUTABLE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: PYTHON_EXECUTABLE
PYTHON_EXECUTABLE-ADVANCED:INTERNAL=1
//This needs to be in PYTHONPATH when 'setup.py install' is called.
Expand Down
4 changes: 2 additions & 2 deletions catkin_ws/build/catkin_generated/order_packages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set(CATKIN_ORDERED_PACKAGES "")
set(CATKIN_ORDERED_PACKAGE_PATHS "")
set(CATKIN_ORDERED_PACKAGES_IS_META "")
set(CATKIN_ORDERED_PACKAGES_BUILD_TYPE "")
list(APPEND CATKIN_ORDERED_PACKAGES "selected_points_publisher")
list(APPEND CATKIN_ORDERED_PACKAGE_PATHS "selected_points_publisher")
list(APPEND CATKIN_ORDERED_PACKAGES "sick_scan")
list(APPEND CATKIN_ORDERED_PACKAGE_PATHS "sick_scan_xd")
list(APPEND CATKIN_ORDERED_PACKAGES_IS_META "False")
list(APPEND CATKIN_ORDERED_PACKAGES_BUILD_TYPE "catkin")
list(APPEND CATKIN_ORDERED_PACKAGES "vision")
Expand Down
2 changes: 1 addition & 1 deletion catkin_ws/build/catkin_make.cache
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
selected_points_publisher:vision
sick_scan_xd:vision
-DCATKIN_DEVEL_PREFIX=/home/rbccps/Desktop/RBCCPS2023/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/rbccps/Desktop/RBCCPS2023/catkin_ws/install -G Unix Makefiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(ORDERED_PATHS "/opt/ros/noetic/lib")
Empty file.
Empty file.
20 changes: 15 additions & 5 deletions computeHomography.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import numpy as np
pts_src=np.array([[-18.5,-18.5,1],[18.5,-18.5,1],[18.5,18.5,1],[-18.5,18.5,1],[-18.5,101.5,1],[18.5,101.5,1],[18.5,138.5,1],[-18.5,138.5,1],[-18.5,221.5,1],[18.5,221.5,1],[18.5,258.5,1],[-18.5,258.5,1],[41.5,341.5,1],[78.5,341.5,1],[78.5,378.5,1],[41.5,378.5,1],[-138.5,221.5,1],[-101.5,221.5,1],[-101.5,258.5,1],[-138.5,258.5,1],[-138.5,101.5,1],[-101.5,101.5,1],[-101.5,138.5,1],[-138.5,138.5,1]]) # planar object points
pts_dst=np.array([[663,451,1],[755,449,1],[740,388,1],[655,390,1],[636,274,1],[712,273,1],[702,234,1],[632,234,1],[620,158,1],[681,159,1],[676,133,1],[616,132,1],[693,81,1],[744,83,1],[735,64,1],[687,62,1],[421,162,1],[482,161,1],[485,133,1],[427,136,1],[392,279,1],[467,278,1],[471,236,1],[401,238,1]]) # image points
pts_src=np.array([[-18.5,18.5,1],[-18.5,-18.5,1],[18.5,-18.5,1],[18.5,18.5,1],[-78.5,-41.5,1],[-78.5,-78.5,1],[-41.5,-78.5,1],[-41.5,-41.5,1],[-18.5,178.5,1],[-18.5,161.5,1],[18.5,161.5,1],[18.5,178.5,1],[-18.5,318.5,1],[-18.5,281.5,1],[18.5,281.5,1],[18.5,318.5,1],[-138.5,138.5,1],[-138.5,101.5,1],[-101.5,101.5,1],[-101.5,138.5,1],[-198.5,258.5,1],[-198.5,221.5,1],[-161.5,221.5,1],[-161.5,258.5,1]]) # planar object points
pts_dst=np.array([[836,462,1],[834,339,1],[743,396,1],[738,460,1],[657,581,1],[670,502,1],[568,497,1],[548,573,1],[823,224,1],[822,191,1],[756,189,1],[754,222,1],[816,131,1],[814,110,1],[758,109,1],[759,139,1],[573,279,1],[586,241,1],[517,242,1],[500,279,1],[516,173,1],[529,147,1],[475,148,1],[459,173,1]]) # image points
import cv2
h, status = cv2.findHomography(pts_src, pts_dst)
# print(h)


pts_src=np.array([[-78.5,341.5],[-41.5,341.5],[-41.5,378.5],[-78.5,378.5],[-18.5,-18.5],[18.5,-18.5],[18.5,18.5],[-18.5,18.5]]) # planar object points
#pts_src=np.array([[-78.5,341.5],[-41.5,341.5],[-41.5,378.5],[-78.5,378.5],[-18.5,-18.5],[18.5,-18.5],[18.5,18.5],[-18.5,18.5]]) # planar object points

pts_src=np.array([[101.5,198.5],[101.5,161.5],[138.5,161.5],[138.5,198.5],[101.5,378.5],[101.5,341.5],[138.5,341.5],[138.5,378.5],[101.5,78.5],[101.5,41.5],[138.5,41.5],[138.5,78.5]]) # planar object test points



# print(np.shape(pts_src))
h=np.array([[2.59275014,1.22742257,703.045769],[0.0176127956,-0.801686794,417.718048],[0.000208861672,0.00224224441,1.00000000]])
pts_dst=np.zeros((3,1)) # image points
distortion_matrix = np.array([-0.44779831 , 0.21493212,0.0086979,-0.00269077,0.00281984])
camera_matrix = np.array([[931.82769928,0,645.03076458],[0,927.95336118,333.43480061],[0,0,1]])
camera_matrix = np.array([[951.66304851,0,643.42125081],
[0,947.84899404,334.96279408],
[0,0,1]])
# print(np.shape(camera_matrix))
# print(np.shape(distortion_matrix))
pts_src_1=[]
Expand Down Expand Up @@ -60,7 +67,10 @@
# print("Hello")

# print(dst)
img_test=np.array([[[523.0],[80.0]],[[576.0],[80.0]],[[574.0],[61.0]],[[525.0],[63.0]],[[663.0],[451.0]],[[755.0],[449.0]],[[740.0],[388.0]],[[655.0],[390.0]]])
#img_test=np.array([[[523.0],[80.0]],[[576.0],[80.0]],[[574.0],[61.0]],[[525.0],[63.0]],[[663.0],[451.0]],[[755.0],[449.0]],[[740.0],[388.0]],[[655.0],[390.0]]])

img_test=np.array([[[1039.0],[233.0]],[[1024.0],[202.0]],[[964.0],[198.0]],[[976.0],[231.0]],[[978.0],[109.0]],[[969.0],[88.0]],[[923.0],[85.0]],[[928.0],[104.0]],[[1089.0],[368.0]],[[1072.0],[321.0]],[[999.0],[319.0]],[[1013.0],[366.0]]])#image test points

# # print(img_test)
img_test_1=[]

Expand Down
4 changes: 2 additions & 2 deletions ground_truth/track_sick.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self):
self.pub = rospy.Publisher("/converted_pc", PointCloud2, queue_size=1)
self.header = Header()
self.rate=rospy.Rate(50)
self.header.frame_id = "laser"
self.header.frame_id = "cloud"
self.fields = [PointField('x', 0, PointField.FLOAT32, 1),
PointField('y', 4, PointField.FLOAT32, 1),
PointField('z', 8, PointField.FLOAT32, 1),
Expand Down Expand Up @@ -109,7 +109,7 @@ def scan_cb(self,msg):
pass

# if lengthplank!=0.0:
if 0.35<=lengthplank<=0.61:
if 0.35<=lengthplank<=0.81:
# if lengthplank>0.0:
# print("again")

Expand Down
Binary file added images/321_Final.zip
Binary file not shown.
Binary file added images/321_Final/saved_img_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/321_Final/saved_img_9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/saved_img_0.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/saved_img_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/saved_img_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/saved_img_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion img_coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def click_event(event, x, y, flags, params):
cv2.circle(img, (x,y), 3, (0,255,255), -1)

# read the input image
img = cv2.imread('checker_points.png')
img = cv2.imread('saved_img.jpg')

# create a window
cv2.namedWindow('Point Coordinates')
Expand Down
2 changes: 1 addition & 1 deletion matrices.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#mainstream # 1280x720
#mainstream # 1280x720
distortion_matrix = np.array[[-0.44779831 0.21493212 0.0086979 -0.00269077 0.00281984]]
camera_matrix = np.array[[931.82769928 0. 645.03076458]
[ 0. 927.95336118 333.43480061]
Expand Down
Binary file added saved_img_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_10.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_11.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_12.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added saved_img_9.jpg

0 comments on commit af29a6c

Please sign in to comment.