Python, MicroPython...
 
Notifications
Clear all

Which (if any) of these Python-related topics do you find interesting? Poll is created on Feb 16, 2021

  
  
  
  
  

Python, MicroPython, CircuitPython

156 Posts
32 Users
65 Likes
6,390 Views
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4016
 

@jasline123 I see that doing this with python is pretty simple. Let us know how it goes.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Jasline123
(@jasline123)
Eminent Member
Joined: 6 months ago
Posts: 20
 

@zander I tried the bus. deinit() but still getting the same error for 2nd camera.


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4016
 

@jasline123 I don't doubt it, you need more than that.Which bus is the first and 2nd cam on, which bus did you specify in the deinit?

What I would do to test the overall idea (I think you are missing some pieces) is to first comment out entirely one of the cameras and test that the 2nd camera works, then do the same for the other camera. If you can get both cameras working by themselves, then modify the code to do effectively the same thing with init and deinit statements. What I mean is

In setup

  deinit 1

  deinit 2

in main loop

  when you want to use 2

  deinit 1

  init 2

  when you want to use 1

  deinit 2

  init 1

 

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Jasline123
(@jasline123)
Eminent Member
Joined: 6 months ago
Posts: 20
 

@zander The cameras are working individually. I tested with commenting each one separately...

But I did not use the deinit, init one correctly as you said...Thanks a lot. I hope this will solve my issue..... 🍻  


   
Ron reacted
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4016
 

@jasline123 I was just using pseudo code, the actual calls will be more like

I2C1.deinit(1);  I2C0.deinit(0);

same for init. I know you may be used to leaving out arguments, but in my opinion that is a poor practice, be specific, so init will be of the form I2C1.init(1, ..... other args

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Jasline123
(@jasline123)
Eminent Member
Joined: 6 months ago
Posts: 20
 

@zander Thank you,...Right now all the errors are gone. But the 2nd camera is not capturing the image...It is returning "None"


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4016
 

@jasline123 Time for problem solving 101, swap cameras, does malfunction move with the camera or stay with the code. Take appropriate action.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Jasline123
(@jasline123)
Eminent Member
Joined: 6 months ago
Posts: 20
 

@zander Thanks Alot...I have one doubt if anyone knows to calculate the frame rate? Connecting ov2640 with raspberry pi pico.I am not sure how to proceed for that


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4016
 

@jasline123 It's not really something to be calculated, you set it according to your requirements. 24 for NTSC, 60 for sports, 30 otherwise. If for PAL, 25 and 50.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Jasline123
(@jasline123)
Eminent Member
Joined: 6 months ago
Posts: 20
 

@zander oooh thanks..Can i ask one more doubt? How can i take video with this camera and rapsberry pi pico...Now i am capturing the image alone


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4016
 

@jasline123 Sorry, I do not know python so no clue but if it was C I would check the library header for comments that may tell you, otherwise just look for the method name they are using. 

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
Jasline123
(@jasline123)
Eminent Member
Joined: 6 months ago
Posts: 20
 

@zander I checked for a method for capturing video but couldn't find one.

 


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4016
 

@jasline123 Does this help?

Screen Shot 2022 09 10 at 09.58.32

 

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
ReplyQuote
robotBuilder
(@robotbuilder)
Noble Member
Joined: 4 years ago
Posts: 1659
 

@jasline123 

This is an example of capturing video using Python and OpenCV on Windows.

import cv2 as cv

capture = cv.VideoCapture(0)
while True:
    isTrue, frame = capture.read()
    cv.imshow('Video',frame)

    if cv.waitKey(20) & 0xFF==ord('d'):
        break
    
capture.release()
cv.destroyAllWindows()

#cv.waitKey(0)

This is an example in the Processing language.

import processing.video.*;

Capture video;

void setup() {
  size(320,240);
  video = new Capture(this, 320, 240);
  video.start();
}

void captureEvent(Capture video) {
  video.read();
}

void draw() {
  image(video, 0, 0, 320,240);
}

 

 

I started playing with video processing a long time ago and use a window's laptop as the main robot "brain".   I use a simple windows only escapi.dll to capture images from any or all of up to 4 connected webcams.

 

This post was modified 5 months ago 6 times by robotBuilder

   
ReplyQuote
Jasline123
(@jasline123)
Eminent Member
Joined: 6 months ago
Posts: 20
 

But I was not able to find the cv2 module in circuit python. And I am not so good with programming. So I got stuck...


   
ReplyQuote
Page 10 / 11