Skip to content

Commit

Permalink
Merge pull request #4 from ashwani-rathee/ash/basic_set
Browse files Browse the repository at this point in the history
Stereo Extension made
  • Loading branch information
ashwanirathee authored Oct 12, 2023
2 parents 70e5e47 + 3077008 commit 5845c09
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Manifest.toml
practice.jl
11 changes: 9 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ version = "0.1.0"
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[weakdeps]
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
VideoIO = "d6d074c3-1acf-5d4c-9a43-ef38773959a2"
FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
GridDetector = "75c2d37c-541b-4fe4-8435-1b4a52ab0cde"

[extensions]
StereoExt = ["GLMakie", "VideoIO", "FFMPEG"]
CalibrateExt = ["GridDetector"]

[compat]
julia = "1"
Expand Down
59 changes: 59 additions & 0 deletions ext/CalibrateExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module CalibrateExt

using GridDetector, VideoIO
using MultipleViewGeometry

function MultipleViewGeometry.calibrate(device;save=false)
cam = VideoIO.opencamera("video=" * device)

count = 0
@info count "Calibrating..."
fps = VideoIO.framerate(cam)
images = []
corners = []

try
while (count < 9)
try
img = Gray.(read(cam))
cam.flush = true

# @info "Info:" cam.flush cam.finished cam.bits_per_result_pixel cam.frame_queue
res = find_checkerboard(img)

if (length(res) == 63)
@info "Checkerboard size:" length(res)
push!(images, img)
push!(corners, res)
count = count + 1
sleep(0.5)
else
sleep(0.01)
end

cam.flush = false
catch e
@info e.message
if typeof(e) <: InterruptException
println("caught Interrupt")
return
end
end
end

if (save == true)
for i in 1:9
save("image-$i.jpg", images[i])
end
end

@info "Images:" length(images)
finally
close(cam)
end

return images, corners
end


end
16 changes: 11 additions & 5 deletions src/videoio.jl → ext/StereoExt.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
using VideoIO, FFMPEG
module StereoExt # Should be same name as the file (just like a normal package)

using MultipleViewGeometry
using GLMakie
using VideoIO
using FFMPEG

function stereo_setup()
function MultipleViewGeometry.stereo_setup()
devices = []
append!(devices, VideoIO.get_camera_devices(FFMPEG, "dshow", "dummy"))
cam1 = VideoIO.opencamera("video=" * devices[4])
cam2 = VideoIO.opencamera("video=" * devices[6])
return cam1, cam2
end


function show_output(cam2, cam1)
function MultipleViewGeometry.show_output(cam2, cam1)
fig = Figure(size = (1000, 700), title = "Stereo View")
ax = GLMakie.Axis(
fig[1, 1],
Expand Down Expand Up @@ -38,6 +41,9 @@ function show_output(cam2, cam1)

node1[] = rotr90(img1)
node2[] = rotr90(img2)
sleep(1 / fps)
sleep(0.5/fps)
end
end


end # module
17 changes: 11 additions & 6 deletions src/MultipleViewGeometry.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ module MultipleViewGeometry

using Reexport

@reexport using CoordinateTransformations
@reexport using Rotations
@reexport using StaticArrays
@reexport using Distances
@reexport using Combinatorics
using CoordinateTransformations
using Rotations
using StaticArrays
using Distances
using Combinatorics
using LinearAlgebra

include("basic_set.jl")
include("videoio.jl")

function stereo_setup end
function show_output end
function calibrate end

export EuclideanPoint, HomogeneousPoint
export Edge, EuclideanNorm, MidPoint, Euclidean
Expand All @@ -28,4 +31,6 @@ export draw_rect
export stereo_setup
export show_output

export calibrate

end

0 comments on commit 5845c09

Please sign in to comment.