{"id":2920,"date":"2021-07-01T09:43:45","date_gmt":"2021-07-01T07:43:45","guid":{"rendered":"https:\/\/www.kurokesu.com\/main\/?p=2920"},"modified":"2021-07-01T18:01:17","modified_gmt":"2021-07-01T16:01:17","slug":"experiments-with-parfocal-motorized-zoom-lens","status":"publish","type":"post","link":"https:\/\/www.kurokesu.com\/main\/2021\/07\/01\/experiments-with-parfocal-motorized-zoom-lens\/","title":{"rendered":"Experiments with parfocal motorized zoom lens"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Motorized zoom camera\u00a0<a target=\"_blank\" href=\"https:\/\/www.kurokesu.com\/shop\/cameras\/C1_PRO_X18\" rel=\"noreferrer noopener\">C1_PRO_X18<\/a>\u00a0has two independent stepper motors for Zoom and Focus control. More specifications can be found in\u00a0<a target=\"_blank\" href=\"https:\/\/wiki.kurokesu.com\/books\/c1-pro-x18\" rel=\"noreferrer noopener\">the documentation<\/a>\u00a0area. By design, this\u00a0<a target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Varifocal_lens\" rel=\"noreferrer noopener\">varifocal<\/a>\u00a0lens means the focus will be lost after the magnification motor is moved. However, the lens has linear rail reference points and it is possible to calibrate the lens so it will behave like much more expensive models.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Parfocal is a type of lens that stays in focus when magnification is changed [<a target=\"_blank\" href=\"https:\/\/en.wikipedia.org\/wiki\/Parfocal_lens\" rel=\"noreferrer noopener\">wiki<\/a>]<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">Calibration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It would be better to automate the calibration process, but for simplicity, clarity and to avoid possible mistakes let&#8217;s do it the manual way.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Get a software package to control lens optical trail from&nbsp;<a target=\"_blank\" href=\"https:\/\/github.com\/Kurokesu\/SCF4-SDK\/tree\/master\/src\/gui_L087%20(for%20C1_PRO_X18%20camera)\" rel=\"noreferrer noopener\">Github<\/a>, open&nbsp;<a target=\"_blank\" href=\"https:\/\/wiki.kurokesu.com\/books\/viewrecordstream-software-overview\" rel=\"noreferrer noopener\">any program<\/a>&nbsp;to preview live camera view, and capture 10-20 points across full zoom range where sharpness is the best.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/gui2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"725\" src=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/gui2-1024x725.png\" alt=\"\" class=\"wp-image-2930\" srcset=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/gui2-1024x725.png 1024w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/gui2-300x212.png 300w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/gui2-768x544.png 768w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/gui2.png 1116w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Save key points to txt file and import to favorite graphing software (Libre Office works just fine) to verify smooth graphs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/ch1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"900\" height=\"556\" src=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/ch1.png\" alt=\"\" class=\"wp-image-2931\" srcset=\"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/ch1.png 900w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/ch1-300x185.png 300w, https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/ch1-768x474.png 768w\" sizes=\"auto, (max-width: 900px) 100vw, 900px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The graph above shows a few calibration curves at different distances, but for this experiment, we need only one. At this point, Python code will handle motion respecting the calibration curve.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Motion script<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Full code is uploaded to\u00a0<a href=\"https:\/\/github.com\/Kurokesu\/SCF4-SDK\/tree\/master\/src\/gui_L087%20(for%20C1_PRO_X18%20camera)%20PARFOCAL_DEMO\" target=\"_blank\" rel=\"noreferrer noopener\">the Github<\/a>\u00a0repository. After accurate calibration sweep script should result in a smooth zoom transition from wide to narrow view angle without loosing sharp focus.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"1140\" height=\"642\" src=\"https:\/\/www.youtube.com\/embed\/Bx-EzOXQeFw?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span>\n<\/div><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Issues and drawbacks<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">While this script adds professional lens features, it should be used as a starting point for developing application-specific code.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Probably the biggest limitation &#8211; calibration works only for a fixed distance.<\/li><li>Another drawback &#8211; lens will change optical train geometry along with ambient temperature, thus sharp focus will be lost.<\/li><li>The initial script version relies on accurate calibration by hand. For standalone operation, this should be automated by implementing a more reliable focus detection algorithm than Laplacian transformation.<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Motorized zoom camera\u00a0C1_PRO_X18\u00a0has two independent stepper motors for Zoom and Focus control. More specifications can be found in\u00a0the documentation\u00a0area. By design, this\u00a0varifocal\u00a0lens means the focus will be lost after the magnification motor is moved. However, the lens has linear rail reference points and it is possible to calibrate the lens so it will behave like [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2925,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[157,153],"tags":[442,354,410,24,392,25,441,49],"class_list":["post-2920","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-projects","tag-algorithm","tag-c1-pro","tag-c1-pro-x18","tag-computer-vision","tag-focus","tag-lens","tag-parfocal","tag-python"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.kurokesu.com\/main\/wp-content\/uploads\/2021\/07\/2.png","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6VSmB-L6","_links":{"self":[{"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/posts\/2920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/comments?post=2920"}],"version-history":[{"count":8,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/posts\/2920\/revisions"}],"predecessor-version":[{"id":2938,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/posts\/2920\/revisions\/2938"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/media\/2925"}],"wp:attachment":[{"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/media?parent=2920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/categories?post=2920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kurokesu.com\/main\/wp-json\/wp\/v2\/tags?post=2920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}